Solved

DirectX3D TextureLoader.FromFile not working with GIF??

Posted on 2009-04-11
4
568 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

624 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