EOSERV Forum > Game Development > Mono: Resources from Windows PE File not loaded correctly
Page: << 1 >>
Mono: Resources from Windows PE File not loaded correctly
Author Message
Post #199467 Mono: Resources from Windows PE File not loaded correctly

I'm currently working on porting my C# client to Ubuntu 15.04 using Mono/MonoGame. I've got it to the point where it is actually launching, the only thing is that graphics aren't loading correctly.

To get around issues porting Win32 P/Invoke calls (LoadLibrary, LoadImage, etc), I wrote my own library that loads a PE File and allows extraction of a resource. Super basic as far as PE loader libraries are concerned. This works great for the mono build of my client on Windows in Visual Studio.

When I run it on Ubuntu, the images are reflected vertically and shifted around. By the time they get to the Texture2D to be displayed by MonoGame, they just show up black (so I suspect their corrupted data is preventing them from being loaded). Here are some samples of what I've found.

When the image object is saved to Bmp or Png file on file system, using System.Drawing.Image.Save:



When the byte array is directly saved to the file system using System.IO.File.WriteAllBytes:



The interesting thing is that when I load the file saved using WriteAllBytes into an Image object, and save it again, it becomes corrupted. So I suspect that Image.FromStream/Image.FromFile is corrupting the data (but since it is a library function that is highly unlikely). I have also tried injecting my own 16-bit bitmap into a test executable and that loads and saves without any issue at all.

I don't have a ton of experience with image formats, so I'm hoping someone here might have an idea about this before I go post this on StackOverflow. I'm pretty sure the byte data I'm getting from the PE file is correct, as indicated by the working File.WriteAllBytes call and the working sample on Windows, just that something between the byte array and the display of the image, things are getting corrupted. For reference here is the file that does the PE loading.

---
class EOSERV {
Programmer | Oldbie
Open source EO Client: https://github.com/ethanmoffat/EndlessClient
};
8 years, 11 weeks ago
Post #199471 Re: Mono: Resources from Windows PE File not loaded correctly

https://github.com/mono/MonoGame/issues/2244 KonajuGames

this is from that link:

8 years, 11 weeks ago
Page: << 1 >>

EOSERV Forum > Game Development > Mono: Resources from Windows PE File not loaded correctly