Einzelnen Beitrag anzeigen

japetos

Registriert seit: 30. Aug 2005
Ort: Montreal
58 Beiträge
 
#3

Re: Fehlermeldung beim Erzeugen eines BMP

  Alt 13. Okt 2005, 22:34
jop soory, war bloed von mir.

Delphi-Quellcode:
procedure TForm1.PrintToFile1Click(Sender: TObject);
var
  bmp: TBitmap;
begin
  bmp := TBitmap.Create;
  try
    bmp.Width := KADaoDBTreeView1.Width;
    bmp.Height := KADaoDBTreeView1.Height;
    bmp.Canvas.Lock;
      try
        KADaoDBTreeView1.Perform(WM_PRINT, bmp.Canvas.Handle, PRF_CHILDREN or PRF_CLIENT or PRF_NONCLIENT);
      finally
        bmp.Canvas.UnLock;
        bmp.SaveToFile('tree.bmp');
        Form2.Image1.Picture.LoadFromFile('tree.bmp')
      end;
  finally
    bmp.Free;
  end;
    Form2.Visible := True;
end;
Delphi-Quellcode:
procedure TForm1.DrawImage(Canvas: TCanvas; DestRect: TRect; ABitmap: TBitmap);
var
  Header, Bits: Pointer;
  HeaderSize: DWORD;
  BitsSize: DWORD;
begin
  GetDIBSizes(ABitmap.Handle, HeaderSize, BitsSize);
  Header := AllocMem(HeaderSize);
  Bits := AllocMem(BitsSize);
  try
    GetDIB(ABitmap.Handle, ABitmap.Palette, Header^, Bits^);
    StretchDIBits(Canvas.Handle, DestRect.Left, DestRect.Top,
      DestRect.Right, DestRect.Bottom,
      0, 0, ABitmap.Width, ABitmap.Height, Bits, TBitmapInfo(Header^),
      DIB_RGB_COLORS, SRCCOPY);
  finally
    FreeMem(Header, HeaderSize);
    FreeMem(Bits, BitsSize);
  end;
end;
  Mit Zitat antworten Zitat