Convert 32768kb EGA file to 256x256 Texture2D?

I'm sorry that this is a kind of question that is not needed, but the original poster, but I'm trying to convert Ultima 4 SHAPES.EGA to Texture2D. Each byte in SHAPES.EGA represents 2 pixels, and there are 256 graphic 16x16. I need to get them squared because the XNA Reach profile does not support image sizes above 2048, regardless of the actual image size. The following code returns me what I want for the first line, but all other lines are not working correctly. (Assuming this is a continuation of this model, the 17th line will look like the second line should look.) I am working on this watch, and I have nothing at the moment.

int cur_size = 16;

GFX.SHAPES_EGA = new Texture2D(GraphicsDevice, cur_size * 16, cur_size * 16);
Color[] temparray = new Color[(cur_size * 16) * (cur_size * 16)];

int CurrentIndex = 0, foo;
for (int Vertical = 0; Vertical < cur_size * 16; Vertical++) //16
{
    for (int Horizontal = 0; Horizontal < 16; Horizontal++)
    {
        for (int CurByte = 0; CurByte < 8; CurByte++)
        {
            //foo = (Vertical * (cur_size / 2)) + (Horizontal * 8 * cur_size) + CurByte;
            foo = (Vertical * (cur_size / 2)) + (Horizontal * 8 * cur_size) + CurByte;
            //Console.WriteLine((CurrentIndex * 2) + "+" + foo);
            temparray[(CurrentIndex*2)] = Basic.EgaToColor((File_SHAPES_EGA[foo] >> 4) & 0x0F);
            temparray[(CurrentIndex*2) + 1] = Basic.EgaToColor(File_SHAPES_EGA[foo] & 0x0F);
            CurrentIndex++;
        }
    }
}
GFX.SHAPES_EGA.SetData(temparray);

The image demonstrates that the image loading code is bugged.

+3
source share
1 answer

Vertical++Try instead Vertical += 16. Thumbs up for Ultima!

+1
source

All Articles