MakeBitmap8() 공개 정적인 메소드

Creates a TRUE 8-bit indexed bitmap from the specified byte array
public static MakeBitmap8 ( int width, int height, byte idx, System.Drawing.Imaging.ColorPalette palette ) : Bitmap
width int width of final bitmap
height int height of final bitmap
idx byte image data
palette System.Drawing.Imaging.ColorPalette
리턴 System.Drawing.Bitmap
예제 #1
0
 public void ReImage()
 {
     image = Bmp.MakeBitmap8(
         Width,
         Height,
         expanded,
         Palette.Colors);
     gray = Bmp.MakeBitmap8(
         Width,
         Height,
         expanded,
         Palette.Grayscale.Colors);
 }
예제 #2
0
        public void MoveImage(byte offset)
        {
            idx[moveIdx] = (byte)(moveVal - offset);
            int ex       = 0;
            int startIdx = 0;

            for (int i = 0; i < expanded.Length; i++)
            {
                expanded[i] = TransparentIndex;
            }

            if (idx[0] != 254)
            {
                ex = idx[startIdx++] * Width;
            }

            for (int i = startIdx; i < idx.Length; i++)
            {
                switch (idx[i])
                {
                case 254:                         // skip required pixels
                    ex += idx[i + 1];
                    i++;
                    break;

                case 255:                         // end of image
                    break;

                default:
                    expanded[ex++] = idx[i];
                    break;
                }
            }

            image = Bmp.MakeBitmap8(
                Width,
                Height,
                expanded,
                Palette.Colors);
            gray = Bmp.MakeBitmap8(
                Width,
                Height,
                expanded,
                Palette.Grayscale.Colors);
        }
예제 #3
0
        public BDYImage(
            Palette p,
            Stream s,
            int width,
            int height)
        {
            BinaryReader data = new BinaryReader(s);

            idx = new byte[width * height];
            for (int i = 0; i < idx.Length; i++)
            {
                idx[i] = 254;
            }

            int x = 0;

            while (data.BaseStream.Position < data.BaseStream.Length)
            {
                int  space = data.ReadByte();
                byte c     = data.ReadByte();

                if (space >= 129)
                {
                    space = 256 - space + 1;
                    for (int i = 0; i < space; i++)
                    {
                        idx[x++] = c;
                    }
                }
                else
                {
                    idx[x++] = c;
                    for (int i = 0; i < space; i++)
                    {
                        c        = data.ReadByte();
                        idx[x++] = c;
                    }
                }
            }
            image   = Bmp.MakeBitmap8(320, 200, idx, p.Colors);
            Palette = p;

            data.Close();
        }
예제 #4
0
        public SPKImage(
            Palette p,
            Stream s,
            int width,
            int height)
        {
//			int transparent = 254;
            idx = new byte[width * height];
            for (int i = 0; i < idx.Length; i++)
            {
                idx[i] = 254;
            }

            long pix = 0;

            BinaryReader data = new BinaryReader(s);

            try
            {
                while (data.BaseStream.Position < data.BaseStream.Length)
                {
                    int cas = data.ReadUInt16();
                    switch (cas)
                    {
                    case 0xFFFF:
                    {
                        long val = data.ReadUInt16() * 2;
                        pix += val;
                        break;
                    }

                    case 0xFFFE:
                    {
                        long val = data.ReadUInt16() * 2;
                        while (val-- > 0)
                        {
                            idx[pix++] = data.ReadByte();
                        }
                        break;
                    }

                    case 0xFFFD:
                    {
                        image = Bmp.MakeBitmap8(
                            width,
                            height,
                            idx,
                            p.Colors);
                        Palette = p;
                        data.Close();
                        return;
                    }
                    }
                }
            }
            catch
            {}

            image = Bmp.MakeBitmap8(
                width,
                height,
                idx,
                p.Colors);
            Palette = p;
            data.Close();
        }
예제 #5
0
        internal PckImage(
            int imageNum,
            byte[] idx,
            Palette pal,
            PckFile pFile,
            int height,
            int width)
        {
            Palette      = pal;
            pckFile      = pFile;
            this.fileNum = imageNum;
//			this.imageNum = imageNum;
//			this.idx = idx;
            staticID = globalStaticID++;

            Height = height;
            Width  = width;

//			image = new Bitmap(Width,Height,PixelFormat.Format8bppIndexed);
            expanded = new byte[Width * Height];

            for (int i = 0; i < expanded.Length; i++)
            {
                expanded[i] = TransparentIndex;
            }

            int ex       = 0;
            int startIdx = 0;

            if (idx[0] != 254)
            {
                ex = idx[startIdx++] * Width;
            }

            for (int i = startIdx; i < idx.Length; i++)
            {
                switch (idx[i])
                {
                case 254:                         // skip required pixels
                    if (moveIdx == -1)
                    {
                        moveIdx = i + 1;
                        moveVal = idx[i + 1];
                    }
                    ex += idx[i + 1];
                    i++;
                    break;

                case 255:                         // end of image
                    break;

                default:
                    expanded[ex++] = idx[i];
                    break;
                }
            }
            this.idx = expanded;

            image = Bmp.MakeBitmap8(
                Width,
                Height,
                expanded,
                pal.Colors);
            gray = Bmp.MakeBitmap8(
                Width,
                Height,
                expanded,
                pal.Grayscale.Colors);
        }