AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Bitmap manuel als icon speichern

Ein Thema von Memnarch · begonnen am 19. Jun 2012 · letzter Beitrag vom 22. Jun 2012
 
Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#2

AW: Bitmap manuel als icon speichern

  Alt 19. Jun 2012, 15:20
sowas nützt Dir wahrscheinlich nichts?

Delphi-Quellcode:
function BitmapToIcon(Bitmap: TBitmap;Size:Integer): TIcon;
var

  IconInfo: TIconInfo;
  IconBitmap, MaskBitmap: TBitmap;
  x, y: Integer;
  TransparentColor: TColor;
begin
  Result:= TIcon.Create;
  IconBitmap:= TBitmap.Create;
  MaskBitmap:= TBitmap.Create;
  try
  IconBitmap.Width:= Size;
  IconBitmap.Height:= Size;
  IconBitmap.Canvas.StretchDraw(Rect(0, 0, Size, Size), Bitmap);
  IconBitmap.TransparentColor:= Bitmap.TransparentColor;
  TransparentColor:= IconBitmap.TransparentColor and $FFFFFF;
  
  MaskBitmap.Assign(IconBitmap);
  for y:= 0 to Size - 1 do
    for x:= 0 to Size - 1 do
      if IconBitmap.Canvas.Pixels[x, y] = TransparentColor then
        IconBitmap.Canvas.Pixels[x, y]:= clBlack;
  IconInfo.fIcon:= True;
  IconInfo.hbmMask:= MaskBitmap.MaskHandle;
  IconInfo.hbmColor:= IconBitmap.Handle;
  Result.Handle:= CreateIconIndirect(IconInfo);
  finally
  MaskBitmap.Free;
  IconBitmap.Free;
  end;
end;
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)

Geändert von Bummi (19. Jun 2012 um 19:47 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:42 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz