Exemplo n.º 1
0
 public MinimapPalette(ImagePalette source, MinimapType type) : this(source, type == MinimapType.Classic?ImagePalette.GetPalette(21):ImagePalette.GetPalette(46))
 {
 }
Exemplo n.º 2
0
 public MinimapPalette(ImagePalette source, ImagePalette minimap)
 {
     this.source  = source;
     this.minimap = minimap;
 }
Exemplo n.º 3
0
 public RenderOptions(ImagePalette pal) : this()
 {
     Palette = pal;
 }
Exemplo n.º 4
0
 public MinimapPalette(ImagePalette source) : this(source, MinimapType.Classic)
 {
 }
Exemplo n.º 5
0
        /// <param name="stream">
        /// Stream containing ILBM image data.
        /// </param>
        public ILBMImage(Stream stream)
        {
            //BinaryReader reader = new BinaryReader(stream, Encoding.ASCII);
            //ReadNext(reader);

            IFFReader reader = new IFFReader(stream);
            var       file   = reader.ReadFileHeader();

            if (file.FormatID != "PBM ")
            {
                throw new NotSupportedException("This is not supported IBLM file.");
            }

            foreach (IFFChunk chunk in reader.ReadAll())
            {
                switch (chunk.TypeID)
                {
                case "BMHD":
                    Width       = reader.ReadInt16();
                    Height      = reader.ReadInt16();
                    PosX        = reader.ReadInt16();
                    PosY        = reader.ReadInt16();
                    NumPlanes   = reader.ReadByte();
                    Mask        = reader.ReadByte();
                    Compression = reader.ReadByte();
                    Padding     = reader.ReadByte();
                    Transparent = reader.ReadInt16();
                    AspectRatio = reader.ReadInt16();
                    PageWidth   = reader.ReadInt16();
                    PageHeight  = reader.ReadInt16();
                    break;

                case "CMAP":
                    Color[] pal = new Color[chunk.Length / 3];
                    for (int i = 0; i < pal.Length; i++)
                    {
                        byte R = reader.ReadByte();
                        byte G = reader.ReadByte();
                        byte B = reader.ReadByte();
                        pal[i] = Color.FromArgb(R, G, B);
                    }
                    Palette = ImagePalette.Create(pal);
                    break;

                case "GRAB":
                    HotspotX = reader.ReadInt16();
                    HotspotY = reader.ReadInt16();
                    break;

                case "CRNG":
                    if (ColorRanges == null)
                    {
                        ColorRanges = new List <ColorRange>();
                    }
                    ColorRanges.Add(new ColorRange(reader));
                    break;

                case "TINY":
                    short  width  = reader.ReadInt16();
                    short  height = reader.ReadInt16();
                    byte[] tiny;
                    if (Compression == 1)
                    {
                        tiny = reader.ReadUnpack(chunk.Length - 4);
                    }
                    else
                    {
                        tiny = reader.ReadBytes(chunk.Length - 4);
                    }
                    Tiny = new TinyImage(width, height, tiny);
                    break;

                case "BODY":
                    if (Compression == 1)
                    {
                        ImageData = reader.ReadUnpack(chunk.Length);
                    }
                    else
                    {
                        ImageData = reader.ReadBytes(chunk.Length);
                    }
                    break;
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Draws bitmap.
 /// </summary>
 /// <param name="data">
 /// Image pixel data.
 /// </param>
 /// <param name="width">
 /// Output image width.
 /// </param>
 /// <param name="height">
 /// Output image height.
 /// </param>
 /// <param name="palette">
 /// Used palette index.
 /// </param>
 /// <returns>
 /// Drawn bitmap.
 /// </returns>
 public static Bitmap DrawBitmap(byte[] data, int width, int height, byte palette)
 {
     return(DrawBitmap(data, width, height, ImagePalette.GetFullPalette(palette)));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Draws plane to bitmap using other palette.
 /// </summary>
 public Image Render(byte palette)
 {
     return(Render(ImagePalette.GetFullPalette(palette)));
 }
Exemplo n.º 8
0
 public JoinPalette(ImagePalette a, ImagePalette b)
 {
     left  = a;
     right = b;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Draws the image to bitmap.
 /// </summary>
 /// <param name="palette">
 /// Palette.
 /// </param>
 /// <returns>
 /// Drawn image.
 /// </returns>
 public Image Render(ImagePalette palette)
 {
     return(Render(new RenderOptions(palette)));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates new instance.
 /// </summary>
 public static RawImage FromBitmap(Bitmap bmp, ImagePalette palette)
 {
     return(new RawImage(Drawing.LoadBitmap(bmp, palette), bmp.Width, bmp.Height));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Joins two palettes together.
 /// </summary>
 /// <param name="a">Left palette.</param>
 /// <param name="b">Right palette.</param>
 /// <returns>Joined palette.</returns>
 public static ImagePalette Join(ImagePalette a, ImagePalette b)
 {
     return(new JoinPalette(a, b));
 }