Reading images from data

Blitz3D Forums/Blitz3D Beginners Area/Reading images from data

Bucky(Posted 2003) [#1]
I was wondering if its possibly to place images into data statments.

In my game the player has a different ship per level - so it makes sense to me to get new ships image and ships variables and speed from the same place

something like this?

.shipdata
data fighter.bmp,3,4,5


if it helps answer my question the player is a type that i read data into.


Neo Genesis10(Posted 2003) [#2]
Enclose fighter.bmp in quotes.
Restore shipdata
Read ship$

.shipdata
Data "fighter.bmp",3,4,4



Ross C(Posted 2003) [#3]
Double post.


Ross C(Posted 2003) [#4]
Yeah, then

ship=loadimage(ship$)



WolRon(Posted 2003) [#5]
Or you can actually include the image of the ship IN THE DATA STATEMENTS. The new 'Visual Blitz' IDE does it automatically for you.


Neo Genesis10(Posted 2003) [#6]
WolRon: All information stored in Data statements MUST be constant values. Therefore, putting in variables such as image handles wont work. And you cannot define images as constants.


GitTech(Posted 2003) [#7]
Neo: maybe he means storing the color for each pixel in the Data statements? That should work :)


keyboard(Posted 2003) [#8]
as Wolron says, like so:

;Load image : bonus.png
Restore IMAGE_DATAS_bonus_png
Read imgW%
Read imgH%
img=CreateImage(imgW,imgH)
SetBuffer ImageBuffer(img)
LockBuffer ImageBuffer(img)
For x=0 To imgW-1
	For y=0 To imgH-1
		Read rgb%
		WritePixelFast x,y,rgb%
	Next
Next
UnlockBuffer ImageBuffer(img)
SetBuffer BackBuffer()

;bonus.png (128x32)
.IMAGE_DATAS_bonus_png
Data 128
Data 32
Data $000000, $000000, $000000, $000000, $000000, $000000, $000000, $000000
Data $000000, $000000, $000000, $000000, $000000, $000000, $000000, $000000
Data $000000, $000000, $000000, $000000, $000000, $000000, $000000, $000000

etc...


visual blitz does it, there are other utilities too.
very handy.


Bucky(Posted 2003) [#9]
Thanks for that help guys - Cheer! ;>


Bucky(Posted 2003) [#10]
joker you wrote - "double post"

what does that mean?


SopiSoft(Posted 2003) [#11]
that he posted twice...