GdkPixbuf verlustfrei in GdkPixmap umwandeln

Für Probleme bezüglich Grafik, Audio, GL, ACS, ...
Antworten
DiBo33
Beiträge: 334
Registriert: Do 11. Okt 2007, 18:01

GdkPixbuf verlustfrei in GdkPixmap umwandeln

Beitrag von DiBo33 »

Hallo,

Code: Alles auswählen

function Pixbuf2HBitmap(Pixbuf: PGDKPixbuf): HBitmap;
const
  alpha_threshold = 151;
var
  Pixmap: PGDIObject;
begin
  Pixmap := GtkWidgetSet.NewGDIObject(gdiBitmap);
  Pixmap^.GDIBitmapType := gbPixmap;
  gdk_pixbuf_render_pixmap_and_mask(Pixbuf, Pixmap^.GDIPixmapObject.Image,
    Pixmap^.GDIPixmapObject.Mask, alpha_threshold);
  Result := HBitmap(PtrUInt(Pixmap));
end;


mit obiger Funktion will ich ein GdkPixbuf in ein HBitmap transferieren.

Hier ist die Qualität aber nicht besonders, wobei ich herausgefunden habe, dass es hauptsächlich am alpha_threshold Wert liegt.
Nun kann ich aber den Wert nicht fix im Programm einsetzen, da der optimale Wert von Grafik zu Grafik jeweils unterschiedlich ist.

Besteht die Möglichkeit den Wert aus einem Pixbuf heraus zu ermitteln oder
kennt jemand eine bessere Möglichkeit als gdk_pixbuf_render_pixmap_and_mask().

Gruß

Antworten