I am surprised that TImage32
does not make transparency. Are you really sure this is so?
In any case, if so, I would combine TImage
transparency TImage
with TImage
re-fetch TBitmap32
to build the solution this way. Save the original image in a TBitmap32
instance. Whenever you need to load it into the TImage
component, for example, when recalibrating, use TBitmap32
to perform an override in memory and load the image with dimensions.
In fact, if you already draw the background, yourself, why not draw the image yourself and just not cope with image management?
Update 1:. Websearch shows an easy way to make TImage32 transparent: http://graphics32.org/news/newsgroups.php?art_group=graphics32.general&article_id=9505
Update 2:. The above link is now dead, and newsgroups can only be accessed through NNTP. I can't be 100% sure, but I think the linked post was Michael Jaralabos and contained the following file:
unit GR32_ImageEx; // Transparent TImage32 by Michael Haralabos interface uses Windows, Messages, Classes, GR32_Image, GR32; type TImage32Ex = class(TImage32) private FTransparent: Boolean; procedure SetTransparent(const Value: Boolean); public procedure ExecClearBackgnd(Dest: TBitmap32; StageNum: Integer); override; published property Enabled; property Transparent: Boolean read FTransparent write SetTransparent; end; procedure Register; implementation procedure TImage32Ex.ExecClearBackgnd(Dest: TBitmap32; StageNum: Integer); var P: TPoint; SaveIndex: Integer; begin if FTransparent and Assigned(Parent) and not (Assigned(Bitmap) and (BitmapAlign = baTile)) then begin SaveIndex := SaveDC(Dest.Handle); GetViewportOrgEx(Dest.Handle, P); SetViewportOrgEx(Dest.Handle, PX - Left, PY - Top, nil); IntersectClipRect(Dest.Handle, 0, 0, Parent.ClientWidth, Parent.ClientHeight); Parent.Perform(WM_ERASEBKGND, Dest.Handle, 0); Parent.Perform(WM_PAINT, Dest.Handle, 0); RestoreDC(Dest.Handle, SaveIndex); end else inherited; end; procedure TImage32Ex.SetTransparent(const Value: Boolean); begin if FTransparent <> Value then begin FTransparent := Value; Invalidate; end; end; procedure Register; begin RegisterComponents('Graphics32', [TImage32Ex]); end; end.
Another topic here says that it could be what the dead link was talking about now: Delphi TImage32 - how to make a component invisible if the image is not loaded?