Пример #1
0
        /// <summary>
        /// Read the 8-bit image into a 2D byte array.
        /// </summary>
        /// <param name="index">Current file reading index.</param>
        private void ReadPictureX0(ref int index)
        {
            uint length = BitConverter.ToUInt16(_bytes, index); index += 2;
            int  width  = BitConverter.ToUInt16(_bytes, index); index += 2;
            int  height = BitConverter.ToUInt16(_bytes, index); index += 2;

            _picture256?.Dispose();
            _picture256 = new Bytemap(width, height);

            byte[] image = DecodePicture(ref index, length);
            int    c     = 0;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (image.Length <= c)
                    {
                        _picture256[x, y] = 0;
                        continue;
                    }
                    _picture256[x, y] = image[c++];
                }
            }
        }
Пример #2
0
 public static IBitmap AddLayer(this IBitmap bitmap, Bytemap layer, int left = 0, int top = 0, bool dispose = false)
 {
     if (layer == null)
     {
         return(bitmap);
     }
     for (int yy = 0; yy < layer.Height; yy++)
     {
         if (top + yy >= bitmap.Height())
         {
             break;
         }
         if (bitmap.OutBoundY(top + yy))
         {
             continue;
         }
         for (int xx = 0; xx < layer.Width; xx++)
         {
             if (left + xx >= bitmap.Width())
             {
                 break;
             }
             if (layer[xx, yy] == 0 || bitmap.OutBoundX(left + xx))
             {
                 continue;
             }
             bitmap.Bitmap[left + xx, top + yy] = layer[xx, yy];
         }
     }
     if (dispose)
     {
         layer.Dispose();
     }
     return(bitmap);
 }
Пример #3
0
        /// <summary>
        /// Read the 4-bit image into a 2D byte array.
        /// </summary>
        /// <param name="index">Current file reading index.</param>
        private void ReadPictureX1(ref int index)
        {
            uint length = BitConverter.ToUInt16(_bytes, index); index += 2;
            int  width  = BitConverter.ToUInt16(_bytes, index); index += 2;
            int  height = BitConverter.ToUInt16(_bytes, index); index += 2;

            _picture16?.Dispose();
            _picture16 = new Bytemap(width, height);

            byte[] image = DecodePicture(ref index, length);
            int    c     = 0;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    _picture16[x++, y] = (byte)(image[c] & 0x0F);
                    _picture16[x, y]   = (byte)((image[c++] & 0xF0) >> 4);
                }
            }
        }
Пример #4
0
 public void Clear()
 {
     _bitmap?.Dispose();
     _bitmap = null;
 }
Пример #5
0
 public void Dispose()
 {
     _bitmap.Dispose();
 }