Solved

DirectX3D TextureLoader.FromFile not working with GIF??

Posted on 2009-04-11
4
562 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

17 Experts available now in Live!

Get 1:1 Help Now