Beispiel #1
0
        public Bitmap GetTextureBitmap(int startPixel, System.Drawing.Color[] palette, uint width, uint height)
        {
            Bitmap     Texture    = new Bitmap((int)width, (int)height);
            LockBitmap lockBitmap = new LockBitmap(Texture);

            lockBitmap.LockBits();
            ushort textW2 = (ushort)(Texture.Width * 2);
            ushort textW4 = (ushort)(Texture.Width * 4);

            for (ushort x = 0; x < width; x++)
            {
                byte xMOD16  = (byte)(x & 15);
                byte xMOD8   = (byte)(x & 7);
                byte xOVER16 = (byte)(x >> 4);
                for (ushort y = 0; y < height; y++)
                {
                    int offset = 32 * (xOVER16) + (4 * (xMOD16)) - (30 * ((xMOD16) >> 3)) + ((System.Byte)(y & 1)) * textW2 +
                                 ((System.Byte)(y >> 2)) * textW4 + ((((System.Byte)(y & 3)) >> 1) +
                                                                     (((xMOD8) >> 2) * -1 + (1 - ((xMOD8) >> 2))) * 16 * (((System.Byte)(y & 3)) >> 1) + (((xMOD8) >> 2) * -1 +
                                                                                                                                                          (1 - ((xMOD8) >> 2))) * 16 * (((System.Byte)(y & 7)) >> 2)) * (1 - (((System.Byte)(y & 7)) >> 2) * (((System.Byte)(y & 3)) >> 1)) +
                                 (((System.Byte)(y & 7)) >> 2) * (((System.Byte)(y & 3)) >> 1);

                    if (startPixel + offset < timBinary.Buffer.Length)
                    {
                        lockBitmap.SetPixel(x, y, palette[timBinary.Buffer[startPixel + offset]]);
                    }
                }
            }
            lockBitmap.UnlockBits();
            return(Texture);
        }
Beispiel #2
0
        public Bitmap GetPatchBitmap(int startPixel, System.Drawing.Color[] palette, uint width, uint height)
        {
            Bitmap     Texture    = new Bitmap((int)width, (int)height);
            LockBitmap lockBitmap = new LockBitmap(Texture);

            lockBitmap.LockBits();
            for (ushort x = 0; x < width; x++)
            {
                for (ushort y = 0; y < height; y++)
                {
                    lockBitmap.SetPixel(x, y, palette[timBinary.Buffer[startPixel + (y * width) + x]]);
                }
            }
            lockBitmap.UnlockBits();
            return(Texture);
        }