Solved

DirectX3D TextureLoader.FromFile not working with GIF??

Posted on 2009-04-11
4
563 Views
Last Modified: 2013-11-05
(Sorry, only have 235 points)

I'm trying to execute line 23 (below). However, it draws a vague 'Error in the application' error message. I tried the same line with a BMP and PNG, both worked perfect. I need it to work in GIF format, however.

On MSDN it says, "This method supports the following file formats: .bmp, .dds, .jpg, .png, and .gif. ":

http://msdn.microsoft.com/en-us/library/ms130475.aspx
private Device device;

        private Texture texture;

 

        public Form1()

        {

            InitializeComponent();

 

            PresentParameters present;

            present = new PresentParameters();

            present.Windowed = true;

            present.SwapEffect = SwapEffect.Discard;

            device = new Device(0, DeviceType.Hardware, this.displayBox,

                CreateFlags.SoftwareVertexProcessing, present);

            device.DeviceReset += OnDeviceReset;

            OnDeviceReset(null, EventArgs.Empty);

        }

 

 

        private void OnDeviceReset(object sender, EventArgs e)

        {

            try

            {

                texture = TextureLoader.FromFile(device, Directory.GetCurrentDirectory() + "\\graphics\\tileset.gif", 0, 0, 1, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, Color.Magenta.ToArgb());

            }

            catch(Exception ex){

                MessageBox.Show(ex.Message.ToString());

            }

        }

Open in new window

0
Comment
Question by:crnghtz
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:Xcone
ID: 24121442
I'm not really familiar with manual texture loading (XNA ftw :-) ), but I've seen kind of question many times before. Try verifying your gif texture is a power 2 in size.
IE: 2*2, 4*4, 2*4 ........ 256*512, 512*512 etc.

200*200 is invalid.
0
 
LVL 4

Expert Comment

by:Xcone
ID: 24121454
more specificly: 200*200 is ofcouse not the only one which is invalid. Your texture height or width must be any of the follwing:
2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048.

I'm not really sure about 2048, but I know there's a maximum size.
0
 

Author Comment

by:crnghtz
ID: 24121495
I made the gif 256*512 and still got the error.

The funny thing is, I can't find an example online where someone is using a GIF with this method.
0
 

Accepted Solution

by:
crnghtz earned 0 total points
ID: 24155107
I found the answer on the XNA forum:

Internally it (the method) calls

http://msdn.microsoft.com/en-us/library/bb172759(VS.85).aspx

which doesn't support gif.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now