Page 1 of 1

GetGadgetAttribute(#canvas, #PB_Canvas_Imag

Posted: Tue Oct 30, 2018 4:59 pm
by akj
I wish to take the image from a canvas gadget, crop it, save it as a separate image and eventually print it.
My code [within a much longer program] is something like this:

Code: Select all

#canvas = 1
StartDrawing(PrinterOutput())
  imageID = GetGadgetAttribute(#canvas, #PB_Canvas_Image) ; #canvas is the gadget number for my canvas gadget
  imageCropped = GrabImage(image, #PB_Any, 200, 250, 20, 25) ; Last 4 numbers define the cropping area
  DrawImage(ImageID(imageCropped), 0, 0)
StopDrawing()
The trouble is that GetGadgetAttribute() returns an image ID but GrabImage() requires an image number. Thus I need the inverse of the ImageID() function, which I would have thought was impossible. How should I proceed?

Re: GetGadgetAttribute(#canvas, #PB_Canvas_Imag

Posted: Tue Oct 30, 2018 6:00 pm
by RASHAD
Hi
Use instead
Result = GrabDrawingImage(#Image, x, y, Width, Height)

But
This command does Not work With PrinterOutput().

Code: Select all

#canvas = 1
#image = 10
StartDrawing(CanvasOutput(#canvas))
  GrabDrawingImage(#image,200, 250, 20, 25)
StopDrawing()

StartDrawing(PrinterOutput())
  DrawImage(ImageID(#image), 0, 0)
StopDrawing()

SaveImage(#image,GetHomeDirectory()+"Test.bmp")


Re: GetGadgetAttribute(#canvas, #PB_Canvas_Imag

Posted: Wed Oct 31, 2018 8:10 pm
by akj
Thank you Rashad for your very helpful answer, which works.