Einzelnen Beitrag anzeigen

cltom

Registriert seit: 22. Sep 2005
221 Beiträge
 
Delphi 12 Athens
 
#1

PaintBox in ScrollBox nach JPG

  Alt 7. Mär 2014, 10:13
Hallo,

folgende Prozedur verwende ich, um aus den Inhalt einer PaintBox in eine JPG zu speichern (siehe unten). Das Ding hab ich ziemlich sicher irgendwo hier auf der DP gefunden. Sie funktioniert auch bestens. Allerdings nicht so ganz, sich die PaintBox innerhalb einer ScrollBox befindet. Da hab ich nämlich dann die ScrollBalken der ScrollBox mit drauf (nebst einem schwarzen Rand).

Woher kommt das und hat jemand eine idee, wie ich es abstellen kann?

danke, grüße
cltom

Delphi-Quellcode:

{*******************************************************************}
procedure TUserInterfaceOps.PaintBoxToJPGClip(apbx : TPaintBox; filename : string; toclip : boolean);
{*******************************************************************}
var
  img_jpg : TImage;
  jpg : TJpegImage;
  jpgformat : word;
  adata : THandle;
  apalette : HPalette;
begin

  img_jpg := TImage.Create(nil);
  img_jpg.Visible := false;

  img_jpg.Width := apbx.Width;
  img_jpg.Height := apbx.Height;

  if assigned(img_jpg.Picture.Graphic) then
  begin
    img_jpg.Picture.Graphic.Width:= apbx.Width;
    img_jpg.Picture.Graphic.Height:= apbx.Height;
  end;

  img_jpg.Canvas.CopyRect(Bounds(0,0,img_jpg.Width, img_jpg.Height),apbx.Canvas, apbx.ClientRect);

  jpg := TJpegImage.Create;
  with jpg do
    begin
      Assign(img_jpg.Picture.Graphic);
      if toclip then
        begin
          jpg.SaveToClipboardFormat(jpgformat, adata, apalette);
          ClipBoard.SetAsHandle(jpgformat,adata);
        end
      else
        SaveToFile(filename);
      Free;
    end;

  img_jpg.free;

end;
  Mit Zitat antworten Zitat