Link to home
Start Free TrialLog in
Avatar of amitbueno
amitbueno

asked on

Delphi Canvas.Draw explaination....

I've created a transparent TBitmap object. Now I am trying to Use the following function in order to copy it ontop an existing TGraphic Object using the transparency capabilities of the object:

:
ABitmap: TBitmap;
Image1: TImage;
:
:
          ABitmap.Transparent := True;          //transparency prepare
          ABitmap.TransparentMode := tmFixed;
          ABitmap.TransparentColor := ABitmap.Canvas.Pixels[0,0];
          ABitmap.Canvas.CopyMode := cmSrcCopy;

          image1.Picture.Bitmap.Canvas.CopyMode := cmSrcCopy;
          image1.Picture.Bitmap.Canvas.draw(0,0,ABitmap);  //draw

Open in new window


This function seems to copy the ABitmap ontop of the Image1 bitmap canvas. Yet, the result seems to be inverted / or monochromed on it. I've created a dummy Image2 object, and assigned the ABitmap to it -- and colors seems to be ok...

The copy mode doesn't seems to make any difference, changing it won't change the canvas.draw function result. I tried to copy the ABitmap with the CopyRect function.... Which which I am having some issues as well.... When using the CopyMode := cmSrcCopy with CopyRect, it display a filled rectangle and not the canvas itself.

In addition I've been having problems using BitBlt function with the SRCCOPY option.... Which for some reason seems to preduce a differrent output than what I thought it will produce...
Avatar of developmentguru
developmentguru
Flag of United States of America image

I guess my first question would be, "What version of Delphi?"
Avatar of amitbueno
amitbueno

ASKER

I am using Delphi XE2, standard VCL (not FMX).
I managed to somehow overcome the issue, by using a component I once bought from envisionstudio.com called ImageScrollBox.... Using that there was no problem copying transparent bitmap onto it.
Yet, I would like to know how to solve that using the standard VCL TImage/TBitmap components.
SOLUTION
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I looked at the links, yet didn't implement them on the code itself....
All links are using the SrcCopy flag, which is implemented whether it is the default flag value when creating a memory bmp component.... or whether you hard code it into the source.

The problem I have is that either ways doesn't do what it documented to do... As you see on my previous post, I am creating a memory TBitmap component, and do apply that to the image... but the SrcCopy doesn't function as it is required to be functioning...

I believe that there might be another flag somewhere in the code I am writing, yet, I didn't find anything that might change the default value...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Look at my previous post...

I know that the canvas.draw function I wrote works properly....  The TBitmap was defined properly with the transparent values within it. It does works on an application I wrote using the TImageScrollBox component (from www.intervalsoftware.com) -- and on other video components that expose the canvas for writing.

According to all the documentation the way I wrote the canvas.draw code, has being done properly... Yet on standard VCL Tcanvas.draw function doesn't draw properly the TGraphics transparency on the final picture -- it does draws the TGraphics -- yet without the transparency features.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I started preparing a Bitmap to send on this thread, then I found my problem.
While initiating a Dest.Canvas.Draw(0,0, Src) -- the Dest wasn't prepared as a bitmap, thus, for some reason, it didn't preform the .Draw procedure properly.

Now it is solved thanks, for the motivation people....