subchannel13 / Stareater

4X turn based strategy
GNU General Public License v3.0
32 stars 7 forks source link

Galaxy texture won't load in Linux+Mono #70

Closed subchannel13 closed 8 years ago

subchannel13 commented 8 years ago

When trying to run Stareater v0.4.5-alpha on Debian with Mono following exception occurres when loading galaxy texture image:

A null reference or invalid value was found [GDI+ status: InvalidParameter] at System.Drawing.GDIPlus.CheckStatus (Status status) <0x403fcc30 + 0x0015f> in :0 at System.Drawing.Bitmap..ctor (System.String filename, Boolean useIcm) <0x4052df30 + 0x0006f> in :0 at System.Drawing.Bitmap..ctor (System.String filename) <0x4052df00 + 0x00013> in :0 at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (string) at Stareater.GLRenderers.GalaxyTextures.Load () <0x4052d2c0 + 0x00063> in :0 at Stareater.GLRenderers.GalaxyRenderer.Load () <0x4052d160 + 0x0001b> in :0 at Stareater.GUI.FormMain.restartRenderers () <0x40520f20 + 0x0011e> in :0 at Stareater.GUI.FormMain.showNewGame () <0x404ab7e0 + 0x000bb> in :0 at Stareater.GUI.FormMain.eventTimer_Tick (System.Object sender, System.EventArgs e) <0x40480a30 + 0x00075> in :0 at System.Windows.Forms.Timer.OnTick (System.EventArgs e) <0x4047e800 + 0x0002f> in :0 at System.Windows.Forms.Timer.FireTick () <0x4047e7d0 + 0x0001e> in :0 at (wrapper remoting-invoke-with-check) System.Windows.Forms.Timer:FireTick () at System.Windows.Forms.XplatUIX11.CheckTimers (System.Collections.ArrayList timers, DateTime now) <0x4047df70 + 0x0031f> in :0 at System.Windows.Forms.XplatUIX11.UpdateMessageQueue (System.Windows.Forms.XEventQueue queue, Boolean allowIdle) <0x4047ba70 + 0x00583> in :0 at System.Windows.Forms.XplatUIX11.UpdateMessageQueue (System.Windows.Forms.XEventQueue queue) <0x4047ba40 + 0x00017> in :0 at System.Windows.Forms.XplatUIX11.GetMessage (System.Object queue_id, System.Windows.Forms.MSG& msg, IntPtr handle, Int32 wFilterMin, Int32 wFilterMax) <0x404784f0 + 0x002d3> in :0 at System.Windows.Forms.XplatUI.GetMessage (System.Object queue_id, System.Windows.Forms.MSG& msg, IntPtr hWnd, Int32 wFilterMin, Int32 wFilterMax) <0x404784a0 + 0x00047> in :0 at System.Windows.Forms.Application.RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) <0x40461720 + 0x00e43> in :0 at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext context) <0x40461670 + 0x00057> in :0 at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) <0x40461360 + 0x00033> in :0 at StareaterUI.Program.Main () <0x40372df0 + 0x000c3> in :0

Problem seams to be rooted deep in how Mono implements workaround for Microsoft's GDI API. I should apply an image loading logic which doesn't rely on GDI in the first place. On the side texture path in GalaxyTexture class has different case then image file.

subchannel13 commented 8 years ago

Looks like path issue due to differing character case. For some reason Mono implementation for System.Drawing.Bitmap(string path) constructor doesn't check if file exist and explodes with wrong error message.

subchannel13 commented 8 years ago

Fix verified.