win32dibi.inc 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. {TODO: create DIBs with the same color depth as the desktop}
  2. Constructor TWin32DIB.Create(AWidth, AHeight : Integer);
  3. Begin
  4. FBitmapInfo := GetMem(SizeOf(BITMAPINFOHEADER) + 12);
  5. FillChar(FBitmapInfo^.bmiHeader, SizeOf(BITMAPINFOHEADER), 0);
  6. With FBitmapInfo^.bmiHeader Do
  7. Begin
  8. biSize := SizeOf(BITMAPINFOHEADER);
  9. biWidth := AWidth;
  10. biHeight := -AHeight;
  11. biPlanes := 1;
  12. biBitCount := 32;
  13. biCompression := BI_BITFIELDS;
  14. biSizeImage := 0;
  15. biXPelsPerMeter := 0;
  16. biYPelsPerMeter := 0;
  17. biClrUsed := 0;
  18. biClrImportant := 0;
  19. End;
  20. PDWord(@FBitmapInfo^.bmiColors)[0] := $FF0000;
  21. PDWord(@FBitmapInfo^.bmiColors)[1] := $00FF00;
  22. PDWord(@FBitmapInfo^.bmiColors)[2] := $0000FF;
  23. FWidth := AWidth;
  24. FHeight := AHeight;
  25. FFormat := TPTCFormat.Create(32, $FF0000, $FF00, $FF);
  26. FPitch := FWidth * 4;
  27. FPixels := GetMem(AWidth * AHeight * 4);
  28. FillChar(FPixels^, AWidth * AHeight * 4, 0);
  29. End;
  30. Destructor TWin32DIB.Destroy;
  31. Begin
  32. FreeMem(FPixels);
  33. FreeMem(FBitmapInfo);
  34. FFormat.Free;
  35. Inherited Destroy;
  36. End;