Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:53 11 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Is it possible to save VGA screen (content) to a file

     Page 1 of 2    
Author Message
Peter63
Regular Member

Joined: 28/07/2017
Location: Sweden
Posts: 66
Posted: 04:54pm 04 Jan 2025
Copy link to clipboard 
Print this post

Hello
Is it possible to save VGA screen (content) to a file?

using: Pico2
PicoMiteVGA MMBasic USB RP2350A Edition V6.00.01R10

/Peter63
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2535
Posted: 05:18pm 04 Jan 2025
Copy link to clipboard 
Print this post

BLIT READ #b, x, y, w, h to read the screen but then how to save. sure it's in the manual

SAVE IMAGE file$ [,x, y, w,
h]
or
SAVE COMPRESSED
IMAGE file$ [,x, y, w, h]
Save the current image on the video output or LCD panel as a BMP file. Any
LCD panel must be capable of being read, for example, a ILI9341 based panel
or a VIRTUAL_M or VIRTUAL_C panel.
'file$' is the name of the file. If an extension is not specified “.BMP” will be
added to the file name. The image is saved as a true colour 24-bit image.
‘x’, ‘y’, ‘w’ and ‘h’ are optional and are the coordinates (‘x’ and ‘y’ are the top
left coordinate) and dimensions (width and height) of the area to be saved. If
not specified the whole screen will be saved.
SAVE COMPRESSED IMAGE will work the same except that RLE
compression will be used to reduce the file size..
Edited 2025-01-05 03:24 by stanleyella
 
Peter63
Regular Member

Joined: 28/07/2017
Location: Sweden
Posts: 66
Posted: 05:42pm 04 Jan 2025
Copy link to clipboard 
Print this post

I'am using MODE 2 (320x240), VGA screen




tested Blit read 1,0,42,319,198
then Error: Not enough Heap memory

tested Save compressed image "pic1.bmp",0,42,319,198
crash , black screen , have to reboot Pico2

/Peter63
 
Peter63
Regular Member

Joined: 28/07/2017
Location: Sweden
Posts: 66
Posted: 05:53pm 04 Jan 2025
Copy link to clipboard 
Print this post

Tested  Save compressed image "pic2.bmp"

it works  jippi  

Why didn't it work with, Save compressed image "pic2.bmp",0,42,319,198

i only want to save a part of the screen

/Peter63
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1575
Posted: 05:54pm 04 Jan 2025
Copy link to clipboard 
Print this post

  Peter63 said  I'am using MODE 2 (320x240), VGA screen

tested Save compressed image "pic1.bmp",0,42,319,198
crash , black screen , have to reboot Pico2 ...


save image "pic3.bmp"

would work.

Regards
Michael

too late ...
Edited 2025-01-05 03:55 by twofingers
causality ≠ correlation ≠ coincidence
 
Peter63
Regular Member

Joined: 28/07/2017
Location: Sweden
Posts: 66
Posted: 06:10pm 04 Jan 2025
Copy link to clipboard 
Print this post

Tested again and it works with: Save image "pic1.bmp",0,42,319,198

This saved the part of the screen i wanted  

/Peter63
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1575
Posted: 06:39pm 04 Jan 2025
Copy link to clipboard 
Print this post

@Peter
Congratulations!

  stanleyella said  ...
SAVE COMPRESSED IMAGE will work the same except that RLE
compression will be used to reduce the file size..

But that's not always true. Be careful: sometimes the RLE overhead is extremely high.
Michael
causality ≠ correlation ≠ coincidence
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2535
Posted: 07:08pm 04 Jan 2025
Copy link to clipboard 
Print this post

  twofingers said  @Peter
Congratulations!

  stanleyella said  ...
SAVE COMPRESSED IMAGE will work the same except that RLE
compression will be used to reduce the file size..

But that's not always true. Be careful: sometimes the RLE overhead is extremely high.
Michael


I was quoting the manual
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1575
Posted: 07:12pm 04 Jan 2025
Copy link to clipboard 
Print this post

  stanleyella said  I was quoting the manual

@Stan
That was directed at Peter and not a criticism of you!
I was surprised myself that the compression is so ineffective.
Regards
Michael
causality ≠ correlation ≠ coincidence
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2535
Posted: 07:40pm 04 Jan 2025
Copy link to clipboard 
Print this post

I never used it but knew it's one of mmb's comprehensive commands somewhere in the comprehensive manual. I've read sci-fi novels with less pages  
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1575
Posted: 07:45pm 04 Jan 2025
Copy link to clipboard 
Print this post

I just looked at the MicroMite manual today. Just over 70 pages. Picomite triples that. An amazing evolution!
causality ≠ correlation ≠ coincidence
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2535
Posted: 08:07pm 04 Jan 2025
Copy link to clipboard 
Print this post

I'm using the latest manual and it covers the 2350 as well... a bit.. but not moaning.
I would like to put in some words about pico 2 and resolution and cpu speed and is it automatic and other stuff but don't want to upset anyone.
cos it's too late anyway :)
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2535
Posted: 08:22pm 04 Jan 2025
Copy link to clipboard 
Print this post

  twofingers said  I just looked at the MicroMite manual today. Just over 70 pages. Picomite triples that. An amazing evolution!



 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7858
Posted: 08:36pm 04 Jan 2025
Copy link to clipboard 
Print this post

Only wondering....
I wonder if it's possible to create an integer array then point its address at the start of the frame buffer? It might then be possible to save the array (i.e. the frame buffer) to a file as a numeric array and possibly even load it straight back into the screen by pointing an empty array then filling it from the file. This would be completely non-standard and incompatible with everything but it would get rid of (or at least reduce) buffering issues that might fill up heap memory.
just a muse....
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
EDNEDN
Senior Member

Joined: 18/02/2023
Location: United States
Posts: 139
Posted: 09:32pm 04 Jan 2025
Copy link to clipboard 
Print this post

  Mixtel90 said  Only wondering....
I wonder if it's possible to create an integer array then point its address at the start of the frame buffer? It might then be possible to save the array (i.e. the frame buffer) to a file as a numeric array and possibly even load it straight back into the screen by pointing....


Yes.   And the other thing it would allow you to do is directly index into the array to update screen values.    I do like the idea.   And it would be almost trivial to implement.

But it would be such a hack.   Probably everybody reading this is cringing...
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7858
Posted: 10:29pm 04 Jan 2025
Copy link to clipboard 
Print this post

Including me....   :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2535
Posted: 10:32pm 04 Jan 2025
Copy link to clipboard 
Print this post

you could read the screen area using pixel
it says in the manual that pixel sets a pixel x,y,colour but I've used if pixel(lander_x,lander_y+39)>0 and pixel(lander_x+3,lander_y+39)=>0 and pixel(lander_x+23,lander_y+39)>0 and pixel(lander_x+27,lander_y+39)>0 then end
so this should work to store screen area to array i(c)
but it doesn't say pixel will read a pixel in the manual

for y=y1 to y2
for x=x1 to x2
 i(c)=pixel x,y
 inc c
next x
next y
Edited 2025-01-05 08:54 by stanleyella
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7858
Posted: 10:55pm 04 Jan 2025
Copy link to clipboard 
Print this post

But if you create a blank array of the correct size then change it's address so that it points to the frame buffer instead of the variables area then instantly the whole screen is in the array. True, you are left with the original blank array still taking up space in the variables area. That might prevent it from working, but if it was only during the time needed to save the array it could then have it's original address poked back in, it could then be destroyed.

Remember, I'm not a programmer and I'm probably missing something that's obvious.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5056
Posted: 11:06pm 04 Jan 2025
Copy link to clipboard 
Print this post

Mick,

I am sure you can read the address of an array. But I expect you cannot change (write) it.

But why would you, you can peek and poke every location on screen if you know the screen start address mm.info()

Volhout
PicomiteVGA PETSCII ROBOTS
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2535
Posted: 11:12pm 04 Jan 2025
Copy link to clipboard 
Print this post

well my lunar lander don't work as pixel has changed so can't find read pixel if it exists
The manual says
PIXEL( x, y) Returns the colour of a pixel on the video output or LCD display. 'x' is the horizontal coordinate and 'y' is the vertical coordinate of the pixel.

but also says
PIXEL x, y [,c] Set a pixel on a video output or an attached LCD panel to a colour.
'x' is the horizontal coordinate and 'y' is the vertical coordinate of the pixel. 'c'
is a 24 bit number specifying the colour. 'c' is optional and if omitted the
current foreground colour will be used.
All parameters can be expressed as arrays and the software will plot the
number of pixels as determined by the dimensions of the smallest array. 'x' and
'y' must both be arrays or both be single variables /constants otherwise an error
will be generated. 'c' can be either an array or a single variable or constant.
edit it was old lander. this works if wanted to be added to vga games

'lunar lander vga 640x480
 OPTION EXPLICIT
 OPTION BASE 1
 option autorun on
 'landscape data
 dim integer lx(43)=(0,5,9,13,3,18,25,30,48,53,57,47,32,11,5,9,57,89,108,149,170,220,262,300,320,400,447,493,510,545,572,600,638,605,590,577,560,513,495,470,457,500,639)
 dim integer ly(43)=(9,17,15,25,40,70,100,130,130,160,193,253,298,346,420,430,430,400,370,457,450,400,440,466,424,400,460,460,452,403,373,320,240,210,190,170,130,120,137,110,60,26,9)
 dim integer l,o,fno,fnc,spnum,k,spc
 dim lander_x,lander_y,last_lander_x,last_lander_y,gravity,inertia,antigravity,fuel
 lander_x=260:lander_y=10:gravity=0.0001:inertia=0:fuel=100
 '
 mode 1
 
 cls
 '
 sprites 'set up lander sprites
 text 170,180,"d         a         g         s         f" 'keys
 for l=1 to 6
   sprite WRITE l,l*80,200 'draw all sprites
 NEXT
 '
 text 210,120,"Press any key to start"
 do:loop until inkey$<> ""
 '
 FRAMEBUFFER CREATE F
 FRAMEBUFFER WRITE f
 cls RGB(black)
 Line GRAPH lx(),ly()'draw landscape
 '
 text 0,470,"FUEL"
 spnum=1
 '--------------------------------------
 do
   if fuel>0 then
     text 48,470,str$(fuel)," "
     k = asc(inkey$)
     if k then 'key presses
       spc=20 'set counts until no flame
       select case k
         Case 100 'd up
           spnum=2
           gravity=gravity-.005
           inc fuel,-.8
         Case 115 's left
           spnum=5
           inertia=inertia-0.005
           inc fuel,-.4
         Case 102 'f right
           spnum=6
           inertia=inertia+0.005
           inc fuel,-.4
         case 103  'g up/right
           spnum=4
           inertia=inertia+0.005
           gravity=gravity-.005
           inc fuel,-1.2
         case 97  'a up/left
           spnum=3
           inertia=inertia-0.005
           gravity=gravity-.005
           inc fuel,-1.2
       end select
     endif
   end if
'
   last_lander_x=lander_x:last_lander_y=lander_y
   lander_y=lander_y+gravity
   lander_x=lander_x+inertia
   gravity=gravity+.00015
   '
'has lander landed, check 2 pixels under each foot all lit
   if pixel(lander_x,lander_y+40)=rgb(white) then
    if pixel(lander_x+3,lander_y+40)=rgb(white) then
     if pixel(lander_x+23,lander_y+40)=rgb(white) then
      if pixel(lander_x+27,lander_y+40)=rgb(white) then text 240,150, "Landed": framebuffer COPY f,N:end'--------
      end if
     end if
    end if  
   end if
'
'has lander hit landscape, check pixels around it, any lit crashed
   o=pixel(lander_x,lander_y)+pixel(lander_x,lander_y+10)+pixel(lander_x,lander_y+20)+pixel(lander_x,lander_y+30)+pixel(lander_x,lander_y+40)+pixel(lander_x+29,lander_y)
   o=o+pixel(lander_x+29,lander_y+10)+pixel(lander_x+29,lander_y+20)+pixel(lander_x+29,lander_y+30)+pixel(lander_x+29,lander_y+40)+pixel(lander_x+7,lander_y)
   o=o+pixel(lander_x+14,lander_y)+pixel(lander_x+21,lander_y)+pixel(lander_x+7,lander_y+39)+pixel(lander_x+14,lander_y+39)+pixel(lander_x+21,lander_y+39)
   if o>0 then explode:end'--------
'
inc spc,-1:if spc<1 then spnum=1 'no flame if no nav key pressed
inc fnc: if fnc=10 then fnc=0:fno=not fno 'which lander for animation if spc>0
box last_lander_x,last_lander_y,30,39,,0,0 'erase lander
if fno=0 then
 sprite WRITE 1,lander_x,lander_y 'draw noflame lander
else
 sprite WRITE spnum,lander_x,lander_y  'draw flame lander if nav key pressed
end if
'
framebuffer COPY f,N
pause 10
loop
end
'
sub sprites
 ship
 sprite READ 1,86,88,28,39'no flame
'
 ship
 triangle 96,114,100,126,104,114,1'flame straight
 sprite READ 2,86,88,28,39
'
 ship
 triangle 96,114,100,126,104,114,1'flame straight
 triangle 107,107,113,110,107,112,1'right thrust
 sprite READ 3,86,88,28,39
'
 ship
 triangle 96,114,100,126,104,114,1'flame straight
 triangle 92,107,86,110,92,113,1'left thrust
 sprite READ 4,86,88,28,39
'
 ship
 triangle 107,107,113,110,107,112,1'right thrust
 sprite READ 5,86,88,28,39
'
 ship
 triangle 92,107,86,110,92,113,1'left thrust
 sprite READ 6,86,88,28,39
 cls
end sub
'
sub ship'draw ship
 cls
 circle 100,98,8
 box 92,106,16,8
 line 92,114,88,126
 line 107,114,111,126
 line 86,126,90,126
 line 109,126,113,126
end sub
'
sub explode
for o=1 to 24
 circle lander_x+15,lander_y+20,o,1,1,rgb(white)
 framebuffer COPY f,N
 pause 20
next
for o=1 to 24
 circle lander_x+15,lander_y+20,o,1,1,rgb(black)
 framebuffer COPY f,N
 pause 20
next
end sub



Edited 2025-01-05 10:17 by stanleyella
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025