[SDL] Displaying data array

Ken Rogoway Ken at HomebrewSoftware.com
Fri Mar 21 13:44:33 PDT 2008


You can create a surface (texture) that has a 24 bit format (RGB) and then
lock it.  You can then write the data 3 bytes at a time (each triple
representing an RGB value).  You will need to account for the actual byte
width of the surface when advancing to the next row since there can be pad
bytes at the end of a row.

Once you have done this you can unlock the surface, then blit it to the
screen or save it to file.  This is about as fast as you will get.  The only
other thing you can do is if your data doesn't need 24 bits of color to
represent it and you can display it with 256 colors you can do the same
thing as above, but write out a byte at a type to represent a single pixel.
In that case you would create a 8 bit (paletted) surface.

Ken Rogoway
Homebrew Software
http://www.homebrewsoftware.com/
 

-----Original Message-----
From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Ed Keith
Sent: Friday, March 21, 2008 11:26 AM
To: sdl at lists.libsdl.org
Subject: [SDL] Displaying data array

I have an array of data in memory that I want to display as an image. I can
think of two ways of doing this, but do not like either one.

I could write the array to the screen pixel by pixel.
I suspect this will be very slow.

I could write the data to a bit map file and read the file into the display.
I do not like all this unnecessary disk access.

Can anyone suggest a better way?

thank you,

   -EdK

Ed Keith
e_d_k at yahoo.com

Blog: edkeith.blogspot.com


 
____________________________________________________________________________
________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

No virus found in this incoming message.
Checked by AVG. 
Version: 7.5.519 / Virus Database: 269.21.8/1338 - Release Date: 3/21/2008
5:52 PM
 

No virus found in this outgoing message.
Checked by AVG. 
Version: 7.5.519 / Virus Database: 269.21.8/1338 - Release Date: 3/21/2008
5:52 PM
 



More information about the SDL mailing list