Thema: AnimatePNG

Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#74

AW: AnimatePNG

  Alt 26. Mär 2017, 19:48
Ich versuche ein HBitmap in ein GDIPlus konformes Format zu bringen

Delphi-Quellcode:
function BitmapToImage(Hdib: HBitmap): Pointer;
var
  lpImg: Pointer;
  bi: tagBITMAPINFO;
  bm: Bitmap;
  BitmapLength: LongWord;
  bmpBits: TBytes;
  DC: HDC;
begin
  Result := nil;

  DC := GetDc(0);

  if Hdib <> 0 then
  begin
    GetObject(Hdib, sizeof(bm), @bm);

    bi.bmiHeader.biSize := SIZEOF(bi.bmiHeader);
    bi.bmiHeader.biWidth := bm.bmWidth;
    bi.bmiHeader.biHeight := -bm.bmHeight;
    bi.bmiHeader.biPlanes := 1;
    bi.bmiHeader.biBitCount := 32;
    bi.bmiHeader.biCompression := BI_RGB;

    BitmapLength := bm.bmWidth * bm.bmHeight * 4;
    SetLength(bmpBits, BitmapLength + 1);

    GetDIBits(DC, Hdib, 0, bm.bmHeight, @bmpBits[0], bi, DIB_RGB_COLORS);

    if @bmpBits[0] <> nil then
    begin
      if Gdip_CreateBitmapFromScan0(bm.bmWidth, bm.bmHeight, bm.bmWidth * 4, PixelFormat32bppARGB,
        @bmpBits[0], lpImg) = OK then
          Result := lpImg;
    end;
    ReleaseDC(0, DC);
  end;
end;
Es läuft alles durch nur beim aufruf von
GDIP_DrawImageRectRectI kracht es mal wieder.

Ich sehen keinen Fehler in meinem Code.
Eventuell TBytes ?

gruss

Geändert von EWeiss (27. Mär 2017 um 19:34 Uhr)
  Mit Zitat antworten Zitat