Link to home
Start Free TrialLog in
Avatar of crnghtz
crnghtz

asked on

DirectX3D TextureLoader.FromFile not working with GIF??

(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

Avatar of Xcone
Xcone
Flag of Netherlands image

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.
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.
Avatar of crnghtz
crnghtz

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of crnghtz
crnghtz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial