• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

PNG too transparent :-)

Started by marty, 21 July 2008, 20:00:50

Previous topic - Next topic

marty

21 July 2008, 20:00:50 Last Edit: 21 July 2008, 20:10:35 by marty
hi there.

i have a problem. i try to make an image from others png, but the problem is that the blending is not working.

look there:

Image1:

( the link is www.neodivx.be/photo/image1.png )

Image2:

( the link is www.neodivx.be/photo/image2.png )

the code is here:


var
  Img1,Img2,Img3:TImageData;
begin
  InitImage(Img1);
  NewImage(400, 400, ifA8R8G8B8, Img1);


  InitImage(Img2);
  LoadImageFromFile('image1.png',Img2);

  InitImage(Img3);
  LoadImageFromFile('image2.png',Img3);


  CopyRect(Img2,0,0,100,100,Img1,50,50);
  CopyRect(Img3,0,0,43,43,Img1,100,100);

  SaveImageToFile('image3.png',Img1);

  ShowMessage('Done');
end;


the problem is when you look on the image3, you see that in the image, this is transparent.
I would like that In the red round, the image would be a blending between image1 and image2, and not transparent like this


thanks for your help

marty

( Windows Vista sp1, Delphi 2007 sp1 )

Galfar

Well, CopyRect documentation looks like this:

{ Copies rectangular part of SrcImage to DstImage. No blending is performed -
  alpha is simply copied to destination image. Operates also with
  negative X and Y coordinates.
  Note that copying is fastest for images in the same data format
  (and slowest for images in special formats).}
function CopyRect(const SrcImage: TImageData; SrcX, SrcY, Width, Height: LongInt;
  var DstImage: TImageData; DstX, DstY: LongInt): Boolean;

So no blending here - it just copies memory from one image to another.

But I'm currently adding alpha blended drawing to ImagingCanvas class.
It will be ready in 0.26 release of Imaging in week or two.

marty

that would be wonderfull....

I have try:

TPngImage,TPngObject from {Gustavo Huffenbacher Daud (gustavo.daud@terra.com.br)        }

that's work great, but you can not draw on the surface, because this is call like a graphic stuff

GraphicEx:

well doesn't handle the transparency...

GDI+

Work well: it can load a png file, keep the transparency, convert to a bitmap, and i can modify the background via tcanvas.
The problem is the same than your: when you call 2 png, and we you try to blend it, the transparency is kept for the center of the circle...

opengl

well, so fare, i wasn't able to load a png image lol

vampyre:

the best for now: can load and keep the background, can be modify also, but no blending....


If you have any suggestions for png transparent in delphi.....



( i have try with c# visual 2008, the blending is direct, perfect..... )

Galfar

Quote
GDI+
Work well: it can load a png file, keep the transparency, convert to a bitmap, and i can modify the background via tcanvas.
The problem is the same than your: when you call 2 png, and we you try to blend it, the transparency is kept for the center of the circle...

I'm sure GDI+ supports alpha blending somehow (never tries GDI+ though).
There's also AlphaBlend function in basic GDI that should work.
Quote
opengl

well, so fare, i wasn't able to load a png image lol

ImagingOpenGL unit which is a part of Imaging allows you to load PNG and other images directly to OpenGL textures.
Quote
vampyre:

the best for now: can load and keep the background, can be modify also, but no blending....

New canvas functions with blending are already in SubVersion repository so you can try them.

marty


New canvas functions with blending are already in SubVersion repository so you can try them.

[/quote]

could you tell me where to look ?

i've download the new source from svn.

Could you give me a small example of how blending the image together ?
Or just the function to use ?

thanks for your time ;-)

Galfar

Look into ImagingCanvases unit, TImagingCanvas class, methods called DrawAlpha, DrawBlend, StretchDrawAlpha etc.
You can find how to use canvas in ImgBrowser and LCLImager demos, I'll add some blending demo or extend existing one soon.

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk