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
 Filled Rect on transparent layer

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
BionicWave Posted - Feb 13 2012 : 06:11:17
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 ?

2   L A T E S T    R E P L I E S    (Newest First)
BionicWave Posted - Feb 13 2012 : 14:41:52
Wow, this alphachannel.fillrect thing is extremely fast.


Very appreciated.
Thanks.
fab Posted - Feb 13 2012 : 11:13:33
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();