B4J Question Scale/Resize Snapshot image

Declan

Well-Known Member
Licensed User
Longtime User
Hi,
I am using the following code to take a Snapshot of a panel that is 200 X 110.
I then print the image to a printer.
B4X:
    MainForm = Form1
    MainForm.RootPane.LoadLayout("2") 'Load the layout file.
    MainForm.Show
    
    Dim m As Image = MainForm.RootPane.Snapshot

    Dim cv As Canvas
    cv.Initialize("")
    cv.DrawImage(m,0,0,200,100)
    
    Dim P As Printer = Printer_Static.GetDefaultPrinter
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P)
    PJ.PrintPage(cv)
    PJ.PrintPage(pnlQR)
    PJ.EndJob
This works great.
However, the printed image is large and I must reduce the size of the image printed to fit onto the label.
Is there a function that will allow me to Scale or Resize the image prior to printing?
 

TILogistic

Expert
Licensed User
Longtime User
?
B4X:
    Dim m As Image = MainForm.RootPane.Snapshot.As(B4XBitmap).Resize(200,100,True)


    Dim cv As Canvas
    cv.Initialize("")
    cv.DrawImage(m,0,0,m.Width,m.Height)
 
  • Like
Reactions: LGS
Upvote 0
Top