Reading images from data
Blitz3D Forums/Blitz3D Beginners Area/Reading images from data
| ||
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. |
| ||
Enclose fighter.bmp in quotes.Restore shipdata Read ship$ .shipdata Data "fighter.bmp",3,4,4 |
| ||
Double post. |
| ||
Yeah, thenship=loadimage(ship$) |
| ||
Or you can actually include the image of the ship IN THE DATA STATEMENTS. The new 'Visual Blitz' IDE does it automatically for you. |
| ||
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. |
| ||
Neo: maybe he means storing the color for each pixel in the Data statements? That should work :) |
| ||
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. |
| ||
Thanks for that help guys - Cheer! ;> |
| ||
joker you wrote - "double post" what does that mean? |
| ||
that he posted twice... |