ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Wrong transparency in ico file?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

kaju74

Germany
2 Posts

Posted - Aug 20 2015 :  07:21:16  Show Profile  Reply
Hi.

I'm using a very old version of ImageEN (3.1.1) to save an ico file w/ multiple images inside. As soon as I embed an image bith >= 24bit, the generated file couldn't be loaded anymore (in other apps like ArtIcons) due of an invalid transparency data.

How to fix this?

Regards,
Marc

w2m

USA
1990 Posts

Posted - Aug 20 2015 :  09:44:44  Show Profile  Reply
If you do not post any code it is nearly impossible to help you. Having said that, look at ICO_Bitcount and ICO_Background:

ICO_BitCount: TIOICOBitCount;


Description
An array of integers which specifies the the Bitcount of all images contained in an icon file.

The last bitcount must be set to 0.

Example

// save the current image in 'output.ico', It will contain three images with 64x64 32bit (24bit + alphachannel), 32x32 256 colors and 32x32 16 colors

// 64 x 64 x 32bit
ImageEnView.IO.Params.ICO.BitCount[0] := 32;
ImageEnView.IO.Params.ICO.Sizes[0].cx := 64;
ImageEnView.IO.Params.ICO.Sizes[0].cy := 64;

// 32 x 32 x 8bit
ImageEnView.IO.Params.ICO.BitCount[1] := 8;
ImageEnView.IO.Params.ICO.Sizes[1].cx := 32;
ImageEnView.IO.Params.ICO.Sizes[1].cy := 32;

// 32 x 32 x 4bit
ImageEnView.IO.Params.ICO.BitCount[2] := 4;
ImageEnView.IO.Params.ICO.Sizes[2].cx := 32;
ImageEnView.IO.Params.ICO.Sizes[2].cy := 32;

// I don't want other images
ImageEnView.IO.Params.ICO.BitCount[3] := 0;
ImageEnView.IO.Params.ICO.Sizes[3].cx := 0;
ImageEnView.IO.Params.ICO.Sizes[3].cy := 0;

// save
ImageEnView.IO.SaveToFile('D:\output.ico');


and..

TIOParamsVals.ICO_Background

Declaration
property ICO_background: TRGB;

Description
Specifies the color that is used for transparency (i.e. becomes the image background) when loading icon files.

Note: This property must be set before loading. It is not used when saving because only the image's alpha channel is used for transparency. To make a color transparent you use SetTransparentColors before saving.

Example

// Reading
ImageEnView1.IO.Params.ICO_Background := CreateRGB(255, 255, 255);
ImageEnView1.IO.LoadFromFileICO('D:\myicon.ico');

// Writing example
ImageEnView1.Proc.SetTransparentColors(transparent_color, transparent_color, 0);
ImageEnView1.IO.SaveToFileICO('D:\myicon.ico');



Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

kaju74

Germany
2 Posts

Posted - Aug 31 2015 :  01:34:47  Show Profile  Reply
Hi.

Ops - never get a notification about the reply ;-)

Okay, so here's my code (the property 'ImageEnView.IO.Params.ICO' doesn't exist in my ImageEn version!):


  procedure SaveICO(const FileName: string);
  var
    i: Integer;
    Color: TRGB;
  begin
    { initialize arrays }
    FillChar(Editor.IO.Params.ICO_Sizes, SizeOf(Editor.IO.Params.ICO_Sizes), 0);
    FillChar(Editor.IO.Params.ICO_BitCount, SizeOf(Editor.IO.Params.ICO_BitCount), 0);

    { has explicit output formats? }
    if EXImage.ICO.Count > 0 then
    begin
      { get transparent color }
      Color := ImageEnProc.TColor2TRGB(clWhite);

      { iterate through all ico formats... }
      for i := 0 to EXImage.ICO.Count - 1 do
        begin
          { ...and define them! }
          if EXImage.ICO[i].Bits >= 24 then
            Editor. IO.Params.ICO_Background := Color;
          Editor.IO.Params.ICO_Sizes[i].cx := EXImage.ICO[i].Width;
          Editor.IO.Params.ICO_Sizes[i].cy := EXImage.ICO[i].Height;
          Editor.IO.Params.ICO_BitCount[i] := EXImage.ICO[i].Bits;
        end;
    end;

    { save as (multiple) ico }
    Editor.IO.SaveToFileICO(FileName);


So 'Editor' is an instance of ImageEnView and EXImage a collection of the ico output formats...

Regards,
Marc
Go to Top of Page

w2m

USA
1990 Posts

Posted - Aug 31 2015 :  08:19:04  Show Profile  Reply
Look at the icon editor in the imageen demos\fullapps folder.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: