Solved

DirectX3D TextureLoader.FromFile not working with GIF??

Posted on 2009-04-11
4
566 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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