I have recently converted from Image Lists to Virtual Image Lists and Image Collection controls. All my images are stored in the TImageCollection as png files with transparency. They render fine on the toolbar tool buttons but these same images are not rendered as transparent images with TMainMenu. Do I need to render all menus using Owner Draw?
Embarcadero only add the TImageCollection and TVirtualImageList components (the old component does not change). Lot of old components do not call the DoDraw method from the TImageList or TVirtualImageList component (almost each use own method for transparency). Even the components calling the DoDraw method from TImageList don't always work correctly (problems with styles).
They also use 'outdated' methods for transparent images (do not use alpha blending almost in all old components).
I make own descending components (transparent image, speed button, toolbar, tree view, tabcontrol), TImageCollection and TVirtualImageList. But not the TMenu component (use only my version of TImageCollection and TVirtualImageList) because TMenu calls the DoDraw method from TImageList/TVirtualImageList for drawing icons.
I think Embarcadero must change drawing pictures in components. They need call DoDraw method from TImageList/TVirtualImageList in all components with pictures.
Related
How can change alphablend of a form without affect on control in form?
Delphi XE7
One solution to this problem is to use Multi-Device Application (if using VCL is not possible).
If you need to leave a transparent TForm just changing a property Transparency = True.
If you need to leave a semi-transparent component, all components have the Opacity property that can be assigned a more transparent value between 0 and 1, where 0 is closer to that component.
For example you could put the controls within a TLayout and change the Opacity of it as you see fit, and have no effect on the other components, or vice versa.
Actually the answer to this might be pretty simple...(for windows only)
The JEDI VCL library has a component (TJvTransparentForm) that allows you to take an Alpha blended PNG image (ie the gray background shown in your picture above) and use it to make a form control. The picture is actually stored in a TImage and you would need to place your "Icons" on the image itself. Then just respond to the mouse clicks on the TImage.
You have what your asking for (maybe?).
If you were tricky enough you could probably even track the mouse movement and change the Image to glow the correct "button" that the mouse was over.
I want to know how is it possible to animate gif image that is put in TImageList.
I know that if we could access the graphic of each images in TImageList it may be possible cast the graphic of the picture to TGIFImage and set Animate property to true. but the problem is how can we access the image that is loaded in TImageList and cast it to TGIFImage and set that animate property?
EDIT:
How we can have animated gif in TTreeView?
As David Heffernan answered TImageList is not appropriate for saving gif images. but the purpose of this question was to have an animated gif in a treeview. By the suggestion of Remy-lebeau I wrote a unit for that. In this unit I defined two classes. first TGifImageRefrence that uses a TImagelist as its property and must be assigned and has a procedure that add gif image to this imagelist. each frame will be saved as single image in Imagelist and frames' indexes and animationspeed will be saved.
The Second class is TGifNode that its purpose is to be a node in TreeView. It contains a timer an accept a TGifImageRefrence as it's property. you can inherit a class for your own node for your treeview from this class. I write an example using this unit and put them together and you can download it from http://loghman.ir/MySource/GifInTreeView.zip
A TImageList stores a list of equally sized static images. It's not appropriate for hosting an animated GIF. You could unpack all the images from the animated GIF and put them in the images list. And then reconstruct them later for animation. That would seem pointless. You should use TGIFImage for animating a GIF.
I have a Image list assigned to a listview to display transparent images.
There is a slight issue with this regarding some transparent images that are added, and that is they are sometimes hard to see/find in the listview.
See this example image:
You will notice that the images (noticeably the mouse) is barely viewable, infact if a empty image was added you would not even see it, the number captions come to the rescue here to show there is something actually there.
But I would like to make the images visually easier to see. I thought maybe having another image underneath the transparent images would work - of course though it could not affect the actual image.
So with that in mind, I made a bitmap of a chessboard grid:
I feel this would be the most suitable way of representing transparent areas of the images just like Paint.NET etc does.
To further illustrate this example I have modified the original image to show how it would look, if we had the chessboard bitmap as the underlay image:
Having the chessboard there would indicate there is a list item there in the first place, and the bitmap of the chessboard grid could be darker or an altogether different kind of image. As I said earlier if there was no image you would see nothing at all, so better to show an empty chess grid or other bitmap than nothing.
So, how can I display a second image underneath the original images using a imagelist to give a result similar to the example above? The underneath image could be anything - just another loaded bitmap for example.
If you store the chessboard as the first image (with index 0) and make the overlay image from the current image in the OnGetImageIndex event handler, it will do what you want to. However I'm not sure how efficient is to make the overlay image every time the event is fired.
procedure TForm1.ListView1GetImageIndex(Sender: TObject; Item: TListItem);
begin
// make the overlay (with overlay index 1) from the
// image with index Item.Index + 1
ImageList1.Overlay(Item.Index + 1, 1);
// use the first image from the list as a background
Item.ImageIndex := 0;
// and assign just created overlay index for overlay
Item.OverlayIndex := 1;
end;
I seems that what you need is a TImageList with extra capabilities.
As a starting point, I suggests you to consider TImageListEx described in the book Inside Delphi 2006
Excerpt:
The TImageListEx component is a TImageList descendant that can use the
images from another image list to generate disabled images, which can
be used on toolbars and other user interface elements.
The TImageListEx component is a TImageList descendant that can use the
images from another image list to generate disabled images, which can
be used on toolbars and other user interface elements.
There are several benefits of the TImageListEx component:
It eliminates the need for creating disabled glyphs.
It eliminates the need for adding the disabled glyphs to an additional TImageList component at design time.
It can drastically reduce the size of the .dfm file and of the entire application, especially in large applications that use a lot of
glyphs.
It's extremely fast, taking only milliseconds to disable all images in an image list, even when there are number of images.
It's extremely lightweight. (If you add it to an application that already uses the standard TImageList component, it won't increase the
size of the executable at all, and if you add it to an application
that doesn't use the standard TImageList component, the overhead is
only 2 KB.)
It's far from your requirements but yet detailed enough to show how to extend TImageList.
Is there any way to make a control transparent like button, edit, panel or etc...? I mean something like opacity or alpha blend that we have in form property.
Some components have the transparent property. In others you can choose 'none' as the color property. It differs from component to component, but not all components can be made transparent by changing a property.
You should try googling Delphi transparent components, there are downloadable components and tricks you can do to make existing components transparent.
Take a look at the Win32 windows styles, especially WS_TRANSPARENT (or WS_EX_TRANSPARENT).
Applying transparency on a child control can be done very easily using old-fashioned regions and the SetWindowRgn() function.
Applying alpha blending on a child control, on the other hand, is very difficult to do prior to Windows 8. It involves painting the parent window to a bitmap first, then alpha blending an image of the child control on top of the bitmap, then rendering the bitmap onscreen.
In Windows 8, the WS_EX_LAYERED window style (which is what Tform's TransparentColor and AlphaBlendValue properties use internally) has finally been implemented for child controls.
I have a form with an image as the background.
Now I need to put several transparent dark color areas in several areas off the form.
I need not to hide the background. How can I do this?
Standard Delphi control do AFAIK not support that kind of transparency. You therefore have two possiblities:
use third-party components
create your own component (you can derive from an existing one) and override the paint method. In the paint method just draw the correct part of the background image and darken every pixel to get the effect you want.
You can try Delphi 2009/2010 which supports using PNG images. The PNG image format allows for alpha layer transparency, which it sounds it what your looking for. This assumes that your wanting a fixed shape on your form.
EDIT-- For Delphi 2007, you can attempt to use the PNG Components which if I remember correctly do properly handle alpha transparency.
Is the background image and the darker areas the only thing that you want on your form, or do you have other components that should be blended too?
If it's only the background image and the dark areas, I would recommend that you check out Graphics32. It's an image control supporting layers. It should be fairly easy to archive what you want (or what I assume that you want...) from that.