Hi to all.
First, let me say that I've tried all the tips that I've found on the net (so, I'm not a lazy guy).
I'm developing an App for PNA devices (480x272 pixel).
I'm using a PaintBox for background, and a couple more Paintboxes as buttons.
I'm copying the background image to the "button" Paintboxes, so that they do not distinguish from the background.
Now I want to add pictures to the "button" Paintboxes, so that they merge with current canvas content.
I'm not satisfied with transparency, and I can't get any kind of blending working.
I have found some AlphaBlending code for Delphi on the net, but I can't get it working.
Delphi code is expecting TBitmap as input and output, and I have pBitmap. I have no clue what is the difference, and how can I get it to the right form.
Here is the Delphi code (ripped from JanFX component, courtesy of JanSoft, freeware with source):
procedure Blend(src1, src2, dst: tbitmap; amount: extended);
var w,h,x,y:integer;
ps1,ps2,pd:pbytearray;
begin
w:=src1.Width ;
h:=src1.Height;
dst.Width :=w;
dst.Height :=h;
src1.PixelFormat :=pf24bit;
src2.PixelFormat:=pf24bit;
dst.PixelFormat :=pf24bit;
for y:=0 to h-1 do begin
ps1:=src1.ScanLine [y];
ps2:=src2.ScanLine [y];
pd:=dst.ScanLine [y];
for x:=0 to w-1 do begin
pd[x*3]:=round((1-amount)*ps1[x*3]+amount*ps2[x*3]);
pd[x*3+1]:=round((1-amount)*ps1[x*3+1]+amount*ps2[x*3+1]);
pd[x*3+2]:=round((1-amount)*ps1[x*3+2]+amount*ps2[x*3+2]);
end;
end;
end;
I've also tried AlphaBlend function as described here:
http://www.lazarus.freepascal.org/index.php/topic,5930.0.htmlbut all I can get is an application exception.
Anyone with any tip on how can I get this working?