Einzelnen Beitrag anzeigen

Benutzerbild von Dani
Dani

Registriert seit: 19. Jan 2003
732 Beiträge
 
Turbo Delphi für Win32
 
#4

Re: bmp.assign(Image.picture) -->leeres bild????

  Alt 25. Mär 2008, 13:29
Wahrscheinlich reicht es schon, die JPEG-Grafik aus dem TImage in eine TBitmap zu kopieren. Dann:
Delphi-Quellcode:
  ...
  TempBMP.Assign(Pic);
  TempBMP.HandleType := bmDIB;
  with Printer do begin
    ...
    Canvas.StretchDraw(R, TempBMP);
  end;
Ansonsten habe ich hier noch eine uralte Prozedur rumliegen, die (glaube ich) auch mal funktioniet hat.

Delphi-Quellcode:
procedure StretchBitmapToPrinter(TargetCanvas: TCanvas; DestRect: TRect; Bitmap: TBitmap);
var
  BitmapHeader: pBitmapInfo;
  BitmapImage: Pointer;
  HeaderSize: DWORD;
  ImageSize: DWORD;
begin
    GetDIBSizes(Bitmap.Handle, HeaderSize, ImageSize);
    GetMem(BitmapHeader, HeaderSize);
    GetMem(BitmapImage, ImageSize);
    try
      GetDIB(Bitmap.Handle, Bitmap.Palette, BitmapHeader^, BitmapImage^);
      StretchDIBits(TargetCanvas.Handle,
        DestRect.Left, DestRect.Top, // Destination Origin
        DestRect.Right - DestRect.Left, // Destination Width
        DestRect.Bottom - DestRect.Top, // Destination Height
        0, 0, // Source Origin
        Bitmap.Width, Bitmap.Height, // Source Width & Height
        BitmapImage,
        TBitmapInfo(BitmapHeader^),
        DIB_RGB_COLORS,
        SRCCOPY);
    finally
      FreeMem(BitmapHeader);
      FreeMem(BitmapImage);
   end;
end;
Dani H.
At Least I Can Say I Tried
  Mit Zitat antworten Zitat