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.

Newcomers DBPro Corner / Image to Data

Author
Message
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 13th Jul 2006 07:07
I have seen other people have a function which does this, so I have tried to make my own. It is supposed to save the rgb values of each part of an image and then put them into a data statement. I then have a seperate function to read the data statement.

The reading function works perfectly

Here is all the code-



The problem I am having is that it makes the left half of the image into data statements, but it does each one twice, and then does not do the right half of the image.

Can anyone find why? It is the "image_to_data" function that is not working.

Something you may find strange when trying to understand my data staments is that vertical rows in the data statements represents horizontal rows of the image.

I left the data statements from one of my test images in so that you can see my problem.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Jul 2006 22:20
If this is for the space invader challenge, I think we ruled out using data statements from images. Doesn't mean you cant use data to draw images, but a 128x128 image would create an excessive amount of data.
I'll answer the question anyway, code has been tested.

Load an image and write a file containing the DATA statements.



Copy the data from the file into your program and use this code to read it and reproduce the image.


"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 13th Jul 2006 23:25 Edited at: 13th Jul 2006 23:51
Yes, I read that it had been ruled out and that was where I got my inspiration to code it (bad habit I guess.) (You may also not the label was named enemy)

I still don't see what was wrong with my code, but I like yours slightly better anyway, so I am going to make them into functions for use in things other than the coding challenge.

And my image was 10*8, so it wasn't massive.

Edit--

Thanks, it works now...



Login to post a reply

Server time is: 2024-11-26 15:25:09
Your offset time is: 2024-11-26 15:25:09