Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - From Ariel

Pages: [1]
1
@From Ariel:

I checked how Steve's library works and to have it work with InForm you won't actually need the _SOURCE call I imagined initially. You'll need to pass it the actual handle of the PictureBox's helper canvas. In your sample code above, make the following change:

Code: QB64: [Select]
  1. 'No need for BeginDraw DrawScr
  2.  
  3.             'No need for _SOURCE Control(DrawScr).HelperCanvas
  4.  
  5.             exportimage1$ = "testimage.png"
  6.             Result = SaveImage(exportimage1$, Control(DrawScr).HelperCanvas, 0, 0, _WIDTH(Control(DrawScr).HelperCanvas), _HEIGHT(Control(DrawScr).HelperCanvas)) '<-- this is the important change
  7.             IF Result = 1 THEN 'file already found on drive
  8.                 KILL exportimage1$ 'delete the old file
  9.                 Result = SaveImage(exportimage1$, Control(DrawScr).HelperCanvas, 0, 0, _WIDTH(Control(DrawScr).HelperCanvas), _HEIGHT(Control(DrawScr).HelperCanvas)) '<-- same here
  10.             END IF
  11.  
  12.            
  13.            
  14. 'Again, no need for EndDraw DrawScr

That did it but I had to enclose the code inside of the BeginDraw and EndDraw or it didn't even generate an image at all. This may have something to do with the picture box being inside a form vs on the root object IDK. But It works!!!

  [ You are not allowed to view this attachment ]  

2
https://www.qb64.org/forum/index.php?topic=47.msg102649#msg102649

My SaveImage Library is what you’re looking for.  I offered it to be added to the toolkit forum, but it hasn’t been added yet, for whatever reason, so it’d be easy for people to find and make use of.

SMcNeill, sadly this doesn't appear to work with InForm. I get an image but it is blank except for the color of the background of the form created by InForm.

By default it will give me an image of the entire program window. If I enclose it in BeginDraw it only copies the section of the pictureBox I specified but again nothing that was drawn onto it.

Code: QB64: [Select]
  1. BeginDraw DrawScr ' DrawScr is the name of the pictureBox I am drawing to
  2.  
  3.             _SOURCE Control(DrawScr).HelperCanvas ' Fellippe Heitor Said this might help it to target the content but it doesn't seem to work.
  4.  
  5.             exportimage1$ = "testimage.png"
  6.             Result = SaveImage(exportimage1$, 0, 0, 0, _WIDTH, _HEIGHT)
  7.             IF Result = 1 THEN 'file already found on drive
  8.                 KILL exportimage1$ 'delete the old file
  9.                 Result = SaveImage(exportimage1$, 0, 0, 0, _WIDTH, _HEIGHT) 'save the new one again
  10.             END IF
  11.             'PRINT Result
  12.             'PRINT "Our initial Image"
  13.             'IF Result < 0 THEN PRINT "Successful PNG export" ELSE PRINT "PNG Export failed."; Result: ' END
  14.            
  15.            
  16. EndDraw DrawScr
  17.  


3
https://www.qb64.org/forum/index.php?topic=47.msg102649#msg102649

My SaveImage Library is what you’re looking for.  I offered it to be added to the toolkit forum, but it hasn’t been added yet, for whatever reason, so it’d be easy for people to find and make use of.

Thanks I will give this a try!

4
I need to copy a specific portion of the screen and save it to a bitmap (BMP) or PNG file after drawing some stuff to that section of the screen.

I'm having trouble understanding the new _PUTIMAGE vs GET and PUT. I'm not sure how to do this. :(

Pages: [1]