Copy Virtualscreen Content lazarus / 39-Graphics ---------------------------------------------------------------------- eraaijma · 2016-12-14 13:42 Hi guys, I would like to display PDF content in my forms. I have found components: BGRABitmap, BGRAControls and included these in my project I have found libmuPDF.pas and included this in my project too I have found libmuPDF.DLL and put in in the project directory Now I can run the code. So far, so good. After I have selected a PDF, it is loaded into the virtualscreen. If I use the sliders, I can see the whole page is there. Problem:  I cannot get a copy of the whole VirtualScreen Bitmap in my TImage, only the visible part. Questions: What would be the best way to copy the content of the virtualscreen to a Timage? Could this be done if the virualscreen is nowhere visible? I have enclosed some code to demonstrate my point. ---------------------------------------------------------------------- marcov · 2016-12-14 13:56 Most GUI apis only draw what is visible, so it could be that the virtual screen is in the pdf dll. You probably need to investigate how drawing now works. Maybe you can let the pdf dll draw to a sufficiently large bitmap. ---------------------------------------------------------------------- eraaijma · 2016-12-14 14:39 @marcov That is strange. The following code creates an invisible bitmap on the fly, does some painting and then shows it in a visible image. Works like a charm Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function PrepCanvas(var aImage: TImage; var aCanSiz,aDocSiz,aDocMar: TPoint; var aDocSca: Double; var aMsg: String): Boolean;var lOK                         :    Boolean;    aLiBo,aReOn                   :    TPoint;    aBitmap                       :    TBitmap;begin  lOK                           :=   True;  if lOK       then lOK           := CalcScaleOfDocu(aCanSiz,aDocSiz,aDocSca,aMsg);  try    begin      aBitMap                     :=   TBitmap.Create;                                                         {create bitmap}      aBitMap.SetSize(                 aCanSiz.X, aCanSiz.Y);      {calculate centered square: canvas-size - documentsize * documentscale/2}      aLiBo.X                     :=   round((    aCanSiz.X - aDocSiz.X * aDocSca)/2);      aLiBo.Y                   :=   round((    aCanSiz.Y - aDocSiz.Y * aDocSca)/2);      aReOn.X                   :=   round((    aCanSiz.X - aDocSiz.X * aDocSca)/2)+ round(aDocSiz.X*aDocSca);      aReOn.Y                     :=   round((    aCanSiz.Y - aDocSiz.Y * aDocSca)/2)+ round(aDocSiz.Y*aDocSca);      {step 1: clear whole of canvas-area}    aBitMap.Canvas.Brush.Color  :=   clSilver;      aBitMap.Canvas.FillRect(         0,0,      aCanSiz.X,aCanSiz.Y);      {step 2: paint shadow of later drawing}      aBitMap.Canvas.Brush.Color  :=   clGray;      aBitMap.Canvas.FillRect(         aLiBo.X+2,aLiBo.Y+2,aReOn.X+4,aReOn.Y+4);      {step 3: paint drawing area}      aBitMap.Canvas.Brush.Color  :=   clWhite;      aBitMap.Canvas.FillRect(         aLiBo.X-2,aLiBo.Y-2,aReOn.X-4,aReOn.Y-4);      {step 4: Calcluate origin of drawing}      aDocMar.X                   :=               ceil((aCanSiz.X - round(aDocSiz.X * aDocSca))/2) - 4;      aDocMar.Y                 :=   aCanSiz.Y - ceil((aCanSiz.Y - round(aDocSiz.Y * aDocSca))/2) - 4;      {step 5: Display bitmap in Image}      if lOK then                    aImage.Picture.Bitmap.Assign(aBitmap);      FreeAndNil(aBitMap);    end;  except    on e:Exception do    begin    lOK                         :=   False;      aMsg                      :=  'fout met CanvasVulling ' + e.Message;    end;  end;  Result                        :=   lOK;end; ---------------------------------------------------------------------- eraaijma · 2016-12-21 16:00 Solved! Scaling the VirtualScreen solved the problem. Attached a test program. Double click the canvas or drop a PDF, a DXF and a pixel-graphic. - Right-Mouseclick the centre of the canvas to repaint after resizing - Right-Mouseclick the right of the canvas to see the next PDF page - Right-Mouseclick the left of the canvas to see the previous PDF page This program needs to have BGRABitmap and BGRAControls installed. This program also needs libmupdf.dll.