I have been at it for a week now, and I give up. How do you extract PNG images embedded in a TStyleBook
?
I tried this genuine solution, but am getting a strange result. The bitmap shown in my form at design and runtime is that of a TAniIndicator
:
When I open MultiResBitmap
editor of my TImage
I see two scaled versions of the same image.
I used this code to save bitmaps:
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
for i := 0 to Image1.MultiResBitmap.Count - 1 do
Image1.MultiResBitmap.Items[i].Bitmap.SaveToFile(IntToStr(i) + '.png');
end;
And I got two scaled images of this:
So, what happened? How come the image shows one thing and saves another? And how can I save all the images so that I can edit them? And more importantly, after editing, how can I put them back into my TStyleBook
?
The method described in the SO Q&A you referred to (link here) works ok for me. I can however, also create the error you see by copying too much from the style file. Some style files contain several images and since the image data in the .style file is several pages long, it is easy to paint lines past the end of one image and continue with the next one. When you then copy & paste into your TImage, you see one image and then save an other one. Since this is a c&p error I did not investigate further which image is shown and which saved or why.
For your actual problem, editing an image, use the Bitmap Style Designer. Open a .vsf file or select to create a new one. In the submenu of File - New are several alternatives. After a style is loaded or a new one created,
Images
in the treeview on the left, lists all embedded images. With theExport
button in the center header, you can save all images to a directory of your choice. After editing the images(s) you can use theUpdate
button, alternativelyDelete
andAdd
buttons. Finally save as .vsf or .style file. Of some unexplained reason the BSD can only open .vsf files but can save as both .vsf and .style.Edit: Based on your comment that you have a modified style in a stylebook and do not want to create a new one, you can save the style in the stylebook into a .style file. From this .style file you can copy the PNG object into a TImage (while looking at form in text mode) and then at runtime save it to a .png file. After editing in an image editor, load it into a TImage (at design time) and copy (in forms text mode) the PNG as a resource back to the .style file. A kind of a hack, but if nothing else ...