07-16-2023, 12:31 AM
Oh yeah, I remember this one now. I was trying to do something similar just yesterday and was wracking my brain on where I saw it before. I was trying to do a 30 x 75 pixel sprite that would not need a support image file.
I ended up doing a writing data statements to a text file scheme. Which could then be cut & pasted to a program, but yours looks like a much more compact and foolproof solution on the results end of it.
I ended up doing a writing data statements to a text file scheme. Which could then be cut & pasted to a program, but yours looks like a much more compact and foolproof solution on the results end of it.
Code: (Select All)
img& = _LOADIMAGE("yourimagehere.png", 32)
DIM b AS _MEM
b = _MEMIMAGE(img&)
f& = FREEFILE
OPEN "imagedata.txt" FOR BINARY AS f&
cr$ = CHR$(13)
lf$ = CHR$(10)
dt$ = "DATA "
cm$ = ","
m% = 0
DO
IF m% MOD 10 = 0 THEN
IF m% > 0 THEN
PUT #f&, , cr$ 'carriage return put
PUT f&, , lf$ 'line feed
END IF
PUT f&, , dt$ 'data + space here
END IF
_MEMGET b, b.OFFSET + m% * 4, p~&
px$ = _TRIM$(STR$(p~&))
PUT f&, , px$ 'write p~& here
m% = m% + 1
IF m% MOD 10 <> 0 THEN PUT f&, , cm$
LOOP UNTIL m% = b.SIZE / 4
CLOSE f&
PRINT "Done!"
END
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
sha_na_na_na_na_na_na_na_na_na: