save screen i& as 32 bit color .png in qb64

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!
Post Reply
chunkygravy
Newbie
Posts: 1
Joined: Mon Nov 03, 2014 5:12 pm

save screen i& as 32 bit color .png in qb64

Post by chunkygravy »

im trying to save screen i& as a 1000x1000px rgb .png file. in qb64.

SCREEN _NEWIMAGE(1024, 768, 32)
i& = _NEWIMAGE(1000, 1000, 32)
o& = _NEWIMAGE(1024, 768, 32)
_FULLSCREEN
i& = _LOADIMAGE("C:\Documents and Settings\mk2\Desktop\New Folder\M3Maps\3477.png", 32)
SCREEN i&
DIM c(50, 50) AS INTEGER
_MOUSESHOW
FOR x = 0 TO 49
FOR y = 0 TO 49
_MOUSEMOVE (x * 20) + 10, (y * 20) + 10
c& = POINT((x * 20) + 10, (y * 20 + 10))
r = _RED32(c&)
LET c(x, y) = r
NEXT
NEXT

_PUTIMAGE (0, 0)-(500, 500), i&, o&
p& = _LOADIMAGE("C:\Documents and Settings\mk2\Desktop\scale.png")
_PUTIMAGE (600, 300)-(800, 400), p&, o&

SCREEN o&
FOR x = 0 TO 500 STEP 10
LINE (0, x)-(500, x), _RGB(fc, 54, 54)
LINE (x, 0)-(x, 500), _RGB(fc, 54, 54)


NEXT


' c% = POINT (column%, row%)
' pointer_coordinate% = POINT({0|1|2|3})
'LOCATE 1, 1: PRINT c(10, 10)
5 DO: _LIMIT 100 'limit 30
DO WHILE _MOUSEINPUT
m = _MOUSEINPUT
mx = __MOUSEX
my = _MOUSEY
c& = POINT(mx, my)
r = _RED32(c&)
g = _GREEN32(c&)
b = _BLUE32(c&)
a = _ALPHA32(c&)
IF mx > 0 AND mx < 500 AND my > 0 AND my < 500 THEN LOCATE 30, 1: PRINT "Current Color"; r, g, b
IF mx > 0 AND mx < 500 AND my > 0 AND my < 500 AND _MOUSEBUTTON(1) THEN LET nx = INT(__MOUSEX / 10): LET ny = INT(_MOUSEY / 10): LET c(nx, ny) = rw: LOCATE 1, 1: PRINT rw: FOR t = 0 TO 9: LINE (nx * 10 + 1, ny * 10 + t)-(nx * 10 + 9, ny * 10 + t), _RGB(rw, rw, rw): NEXT
IF mx > 600 AND mx < 800 AND my > 300 AND my < 400 THEN LOCATE 30, 30: PRINT "Current Color"; r, g, b
IF mx > 600 AND mx < 800 AND my > 300 AND my < 400 AND _MOUSEBUTTON(1) THEN LET rw = r
' LOCATE 30, 1: PRINT rw
IF INKEY$ = "w" THEN GOTO 10
LOOP
LOOP UNTIL INKEY$ > ""

GOTO 5
10 _FULLSCREEN
SCREEN i&
FOR x = 0 TO 49
FOR y = 0 TO 49
LINE (x * 20, y * 20)-(x * 20 + 20, y * 20 + 20), _RGB(c(x, y), c(x, y), c(x, y)), BF
NEXT
NEXT
SLEEP 5

'insert png save routine

SCREEN o&
LOCATE 1, 1: PRINT "SAVED!"
GOTO 5
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: save screen i& as 32 bit color .png in qb64

Post by burger2227 »

1) You cannot improve the image
2) QB64 has no way to create a PNG from an image.
3) It is already a PNG

Why not just copy it to the new name?
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Post Reply