Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Saving a image as data Statements

Author
Message
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 5th Jun 2009 00:38 Edited at: 5th Jun 2009 00:41
This if function that will save a small image to a text file in data statements.

The images have to be small otherwise you will run into "String overflow" errors :/ but it works for smaller images(i used it for my gui functions so didn't need to have the X and Maximize buttons as external media) although you have to load the image as a bitmap then copy that bitmap to db bitmap so it's in the right format(cuz i need 32 or 16 bit bitmap, most images arn't), then you just call the function with the text file name and the bitmap number and it saves it like this


Data Pixel1Color,Pixel2Color,Pixel3Color
Data Pixel4Color,Pixel5Color,Pixel6Color

and so on. then to use it you just paste it in a subroutine in you program and use dot and ink to draw it like so:

restore MyDataImage:
For Y = 0 to ImageHeight
For X = 0 to ImageWidth
Read Color
ink Color,0
Dot X,Y
Next x
next y

Works pretty good if you ask me.

Heres the function:




New Site! Check it out \/

Login to post a reply

Server time is: 2025-05-15 00:41:33
Your offset time is: 2025-05-15 00:41:33