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
Solved

DirectX3D TextureLoader.FromFile not working with GIF??

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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