[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1188
  • Last Modified:

Convert bitmap or icon to Glyph

Hello experts!
   Please tell me about  format of Glyph file.And how to convert  a file bitmap or icon to Glyph.

Thanks.
0
z27
Asked:
z27
1 Solution
 
kretzschmarCommented:
a glyph is already an ordinary bitmap

to convert an icon to a bitmap,
just could use the stretchdraw mthod of a bitmap.canvas

meikl ;-)
0
 
z27Author Commented:
I know it's a bitmap, but when i try input some *.bmp, it show very bad, i want to know what color of image will be transparent and save bitmap on 8 bit, 24 bit... is best.  
0
 
ComboyCommented:
Hi z27,
Use this code and let me if I've solved your problem ;)

procedure bmp2ico(Image: TImage; FileName: TFilename);
var
  Bmp: TBitmap;
  Icon: TIcon;
  ImageList: TImageList;
begin
  Bmp  := TBitmap.Create;
  Icon := TIcon.Create;
  try
    Bmp.Assign(Image.Picture);
    ImageList := TImageList.CreateSize(Bmp.Width, Bmp.Height);
    try
      ImageList.AddMasked(Bmp, Bmp.TransparentColor);
      ImageList.GetIcon(0, Icon);
      Icon.SaveToFile(FileName);
    finally
      ImageList.Free;
    end;
  finally
    Bmp.Free;
    Icon.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  bmp2ico(Image1, 'c:\test.ico');
end;

Bye till...

Comboy
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now