Image as a background of a form in Delphi - delphi

I'm using Delphi 2006. I have a few PNG images with transparencies and I have to create a GUI using them (top bar, left panel...). The images have different aligns properties. One of the images is the background of the form. The problem here is that I can't align it as alClient because it only occupies the rectangular zone that the other images have left, showing the naked canvas in their transparent zones. What I need is that the background image is put behind all the other images and taking all the canvas size.
Is there anyway to do this? I know I can do this writting some logic in the OnResize event of the form but I was just curious if I was missing something.
Thanks.

Put a TImage on the form and align it with "alClient". Then put an "alClient" aligned Panel on the form. The TPanel is transparent when themes are enabled and "ParentBackground" property is set. Then put the images on the panel and align them at will. If when themes are not enabled is important, you can use a "TJvPanel" which is part of the JVCL library. A search on google also seems to reveal some code for transparent panels.
The above will not help transparency with the "png"s though. AFAIK png support (transparency) is added with D2009 and I don't know if this support includes TImage.
edit: Actually it appears that I owe the very capability to load png images to TImage to the JVCL library itself, and it seems to support transparent "png"s with TImage just fine.

Related

How to apply Anti Aliasing in TImage component with PNG image in real time on Delphi?

I've created an application to display a transparent logo on the screen.
The purpose of this program is to display a logo during multimedia presentations on big screens.
The structure I used in this app is the same as a splash screen.
The difference is that I can switch between transparency mode and form mode by double-clicking the image so that I can resize the logo.
Here is an example of an execution.
The problem, as the image is in a Timage component, it appears with serrated.
Is it possible to apply anti aliasing on the Timage component while maintaining image quality when resizing?

Delphi 2007 - Loading TJvImage from a PNG file loses transparency

I have a couple of TJvImage components on my main form. One is loaded at design time from a partially transparent PNG file. The other is smaller than the first and in front of it. It is loaded at runtime with another partially transparent PNG file.
JvImage1.Picture.LoadFromFile ('Logo.png') ;
JvImage1.Transparent is set to TRUE. The problem is simple: the smaller image is rendered ignoring the alpha channel - i.e. it punches out the background image.
This does not occur when I load both images at design-time. They both show as partially transparent on the form, and display correctly when I run the program.
The real dilemma is that a minimal test program written to try to demonstrate the problem does not show the problem, but the same code in the application proper doesn't behave.
Is there anything about the underlying main form that could affect the behaviour?
I don't know if this is the same for TJvImage but when you set Transparent property of TImage to True it causes TImage to skip rendering any pixel with TransparentColor.
If no transparent color is set the color of lower left pixel is used.
When in such mode TImage doesen't take into accound alpha channel. Infact Transparency only works when you load TBitmap typed image into TImage.
I gues that TJvImage probably works in similar way. So in order to show your image properly you should set the Transparent property to False. This will probably alow TJvImage to render your picture by using Alpha transparency that is encoded to the picture itself.

Delphi TImageList PNG alpha renders too dark

I have PNG icons for my Delphi XE3 application toolbar that, when added to a TActionToolbar via a TImageList, the alpha channel renders darker than it should, causing the icons to look bad. I think the issue has to do with the TImageList and not something specifically with the TActionToolbar.
Photoshop mockup:
Actual look after importing to TActionToolbar (alpha is darker blue for the folder fill):
Here are my Delphi Object Inspector settings for the TImageList (no, the issue is not the BlendColor property):
Is there a way to get Delphi/Windows/whoever the culprit is to render the alpha channel properly? An option is to make the icons all bitmaps, but I'd rather not go through the headache of editing bitmaps with a transparent color because, well, I'd rather not revert to the days of the dinosaurs... TIA.
The best way I found to deal with this is to paint the background color of your Delphi toolbar (or whatever UI element) underneath every pixel that contains transparency in Photoshop before saving the PNG image. This way, the toolbar icons are totally opaque except for the 100% transparent pixels, so there is no alpha blending that takes place--and hence no ugliness.
Use RRUZ's code here to make the disabled toolbar icons look better.

Transparent PNG image (with TImageList) in a TMainMenu

I want to load a PNG with transparent background in a TImageList and use it in a TMainMenu (via TAction).
However, in Delphi the background is just black.
This guy says it worked for him, but with a button instead of a main menu.
My setup:
My image is 8 bit per color plus 8 bit for transparency channel (I have tried also with 1 bit for transparency but still doesn't work). The image looks just fine in any other program.
Delphi XE.
In TImageList's editor, the 'transparent color' and 'Fill color' are set to 'Default' and are disabled.
There's no reason to backup whole DFM file.
Before doing something to your ImageList you should export your images: click the "Export" button in the image list editor and it will save all images to a single .BMP file.
After changing properties: ColorDepth = cd32Bit, DrawingStyle = dsTransparent
You should click "Add" button and select the file you previously exported. Then, images will be drawn with transparency in the menu and toolbars (on D2010 at least)... No need to use 3rd party components.
Set the following property values for TImageList:
DrawingStyle: dsTransparent
ColorDepth: cd32Bit
TImageList's editor -> set the 'transparent color' to True
In "Project Settings" under "Application" set "Enable runtime themes".
Update for Delphi Rio:
TImageList must have:
BkGColor = clNone
BlendColor = clNone,
ColorDepth = cd32bit,
DrawingStyle = dsTransparent (or) dsNormal,
Masked = true.
The images can be loaded from a PNG with transparent bkg color.
Note: Editing some properties of TImageList will delete (without any notice) all existing images in your list. Backup your images (or DFM) first.
I had been using TPngComponents since Delphi 7. That provide very good png support for most of the delphi build-in / third party components. Embarcadero had purchased another well know Open Sources PNG Supporting component know as TPngImage and build into Delphi's native graphic support in later Delphi versions. So when I changed to Delphi 2010, I think Delphi had native support now and test out the native support but find that the alpha support is not good enough.
So I had used back that TPngComponents again and it had better support for most components, including main menu. I think that package should be usable to DXE with limited modification.
edit : Thanks for Uwe Raabe for pointing out the product Codegear (now Embarcadero) purchased was another component TPngImage rather then the TPngComponent.

How can I make a form transparent according to a PNG image?

I have a PNG image that uses transparency (it is actually a circle with gradient effect from black in the middle, to transparent on the margins). I am putting this on a form using TImage. I set TForm1.Color and the TForm1.TransparentColorValue to the same value and TForm1.TransparentColor:=true.
Now, when I run the program the gradient part of the image is displayed with the color of the form. What I am looking for is to enable the transparency of the PNG image using the transparent form effect.
What am I doing wrong?
I am using Delphi 2010 Trial.
I suspect you're trying to create something like a transparent splashscreen, if that's the case, you can read these great articles, they describes a nice way to use a transparent png in a delphi form.
Alpha Blended Splash Screen in Delphi - Part 1
Alpha Blended Splash Screen in Delphi - Part 2
Bye.
Your settings are wrong. I am doing this (With a bitmap).
The TImage.Transparent should be false.
The Form.TransparentColourValue should be the colour of the part of The TImage that you want to be transparent.
The Form.TransparentColor should be True.
[Edit]
It does not matter what colour the form is if the Image covers it completely

Resources