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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Filled Rect on transparent layer
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

BionicWave

Germany
33 Posts

Posted - Feb 13 2012 :  06:11:17  Show Profile  Reply
In ImageEnView i load a bitmap on layer 0.
Now i want to create a transparent-layer and
fill some parts of that with a non-transparent or slightly transparent color.

I do the transparent layer by using AlphaChannel.Fill(0)
and the non-transparent rectangles by setting Alpha(x,y)=255 for
every pixel of a rectangle.

To work that way seems to be a bit of a speed-killer. Is there another way to acomplish the task faster ?

fab

1310 Posts

Posted - Feb 13 2012 :  11:13:33  Show Profile  Reply
There are several ways to speedup this.
First you could direct access to alpha channel buffers. For example this draw a rectangle from x1,y1 to x2,y2:

var palpha:pbyte;
for row:=y1 to y2 do
begin
  palpha := ImageEnView1.IEBitmap.AlphaChannel.Scanline[row];
  inc(palpha, x1);
  for col:=x1 to x2 do
  begin
    palpha^ := 255;
    inc(palpha);
  end;
end;
ImageEnView1.Update();


Alternatively you can handle the alpha channel as a gray scale canvas, using CanvasCurrentAlpha property of TIEBitmap. Example:
ImageEnView1.IEBitmap.AlphaChannel.CanvasCurrentAlpha := 200;
ImageEnView1.IEBitmap.AlphaChannel.Canvas.FillRect(Rect(x1, y1, x2, y2));
ImageEnView1.Update();
Go to Top of Page

BionicWave

Germany
33 Posts

Posted - Feb 13 2012 :  14:41:52  Show Profile  Reply
Wow, this alphachannel.fillrect thing is extremely fast.


Very appreciated.
Thanks.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: