ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TIEBitmap and Pixels_ie1g

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
ksv1991 Posted - Aug 16 2011 : 00:43:02
Hello,

I have a cycle which must stopped, when first found a black point:

for Y := 0 to Image.Height-1 do begin
for X := 0 to Image.Width-1 do begin
if Image.Pixels_ie1g[X,Y] <> true then
break;
end;
end;

But it not working, despite the fact that the loaded image (TIEBitmap) has a black figures.
2   L A T E S T    R E P L I E S    (Newest First)
ksv1991 Posted - Aug 16 2011 : 04:14:09
Thank's! It is working.
fab Posted - Aug 16 2011 : 03:19:22
Hello,
the "break" is inside the inner loop, so it breaks the "X" loop, while the "Y" loop will continue.

You could write (but there are several other options):

var found_flag:boolean;

found_flag := false;
for Y := 0 to Image.Height-1 do
begin
  for X := 0 to Image.Width-1 do 
  begin
    if Image.Pixels_ie1g[X,Y] <> true then
    begin
      found_flag :=  true;
      break;
     end;
   end;
   if found_flag then
     break;
end;