How about doing the following instead of
if self.Canvas.Pixels[j , i] <> ATransparentColor then
    self.Canvas.Pixels[j , i] := clBlack
else
   self.Canvas.Pixels[j , i] := clWhite;

const
 colors : array [boolean] of TColor = (clBlack, clWhite);

self.Canvas.Pixels[j, i] := colors [ self.Canvas.Pixels[j , i] =
ATransparentColor ];

I think it's a bit faster (alto scanline will be even much faster then
that), because it does not uses "if" and but jump to specific address
according to the value ...

Ido

On 6/18/06, Bogusław Brandys <[EMAIL PROTECTED]> wrote:
Hi,


My proposition of patch to fix TBitmap.Mask method used for example for
AddMasked in TImageList. I don't know if it is correct please review
it.It would be valuable to have it as it really simplify retrieving
images from lazarus resource and thus populating internal imagelists for
components like TVirtualTreeview or others.
Of course Mask is still not stored in lazarus resources.

Regards
Boguslaw


Index: bitmap.inc
===================================================================
--- bitmap.inc  (revision 9438)
+++ bitmap.inc  (working copy)
@@ -249,8 +249,20 @@
 end;

 procedure TBitMap.Mask(ATransparentColor: TColor);
+var
+  i , j : Integer ;
 begin
-  DebugLn('TBitMap.Mask not implemented');
+  DebugLn('TBitMap.Mask implemented but really slow.Fix it please');
+  for i := 0 to self.Height - 1 do
+  begin
+    for j := 0 to self.Width - 1 do
+    begin
+    if self.Canvas.Pixels[j , i] <> ATransparentColor then
+     self.Canvas.Pixels[j , i] := clBlack
+     else
+     self.Canvas.Pixels[j , i] := clWhite;
+    end;
+  end;
 end;

 function TBitmap.GetHandle: HBITMAP;




_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to