TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
davidh1
NA
19
0
DirectX(7) and Serialization
Nov 24 2003 12:01 AM
I am writing a game editor for windows as a training exercise to learn C#. In my design, I have a main Windows Form that creates an instance of "GameData" (a class with all the game data) and a separate instance of "ViewForm" which displays the game in a separate window. Saving "GameData" was a breeze. I REALLY, REALLY LIKE the way serialization works in C#. One of the things I wanted to serialize in ViewForm is the sprites. I currently load the sprites from a bunch of BMP bitmaps into DirectX surfaces. (Using DirectX7 in DxVBLib.DLL). I have several arrays like this: ArrayList landscape_sprites = new ArrayList(); ArrayList furniture_sprites = new ArrayList(); ... I then open all the BMP files, load them into surfaces, blt them into individual frames (DX7 surfaces), and load the whole thing into the array lists. What I want to do is SERIALIZE the array lists, but the surfaces are not serializable. I have implemented ISerialize, added a deserialization constructor and GetObjectData(). I figure if I can get the individual frame bitmaps out of the surface and into a byte array (during serialization), and do the reverse (load the byte-array into the surface), I could properly serialize / deserialize my Frames, which means that the sprites would become serializable. Any ideas on how to accomplish this? An alternative is to create the byte arrays or some other kind of serializable structure when I originally create the frames from the BMPs. But I can't seem to find a way to do this either. To load the frames, use "CreateSurfaceFromFile" to create a temporary surface, then I create individual frames and use frame.surface.BltFast() to copy the individual frames from the temporary surface into the individual frame surfaces. I have been unable to find any way to create a surface from a byte array. Dave
Reply
Answers (
0
)
using GDI+ to create the actual form shape
Surface.Lock makes no sense at least to me