Example #1
0
 /// <summary>
 /// The serialise.
 /// </summary>
 /// <param name="serialise">
 /// The serialise.
 /// </param>
 public virtual void Serialise(IwSerialise serialise)
 {
     serialise.UInt32(ref this.hash);
 }
Example #2
0
        /// <summary>
        /// The serialise.
        /// </summary>
        /// <param name="serialise">
        /// The serialise.
        /// </param>
        /// <exception cref="FormatException">
        /// </exception>
        public void Serialise(IwSerialise serialise)
        {
            serialise.UInt8(ref this.format);

            serialise.UInt16(ref this.flags);

            serialise.UInt16(ref this.width);
            serialise.UInt16(ref this.height);
            serialise.UInt16(ref this.pitch);
            uint palette = 0;

            serialise.UInt32(ref palette);
            IImageFormat format = null;

            switch (this.format)
            {
            case ABGR_8888:
                Debug.WriteLine(string.Format("Image ABGR_8888 {0}x{1}", this.width, this.height));
                this.LoadUncompressed(serialise);
                return;

            case BGR_888:
                Debug.WriteLine(string.Format("Image BGR_888 {0}x{1}", this.width, this.height));
                this.LoadUncompressed(serialise);
                return;

            case PALETTE4_ABGR_1555:
                format = (new Palette4Abgr1555(this.width, this.height, this.pitch));
                Debug.WriteLine(string.Format("Image PALETTE4_ABGR_1555 {0}x{1}", this.width, this.height));
                break;

            case PALETTE4_RGB_888:
                format = (new Palette4Rgb888(this.width, this.height, this.pitch));
                Debug.WriteLine(string.Format("Image PALETTE4_RGB_888 {0}x{1}", this.width, this.height));
                break;

            case PALETTE8_ABGR_1555:
                format = (new Palette8Abgr1555(this.width, this.height, this.pitch));
                Debug.WriteLine(string.Format("Image PALETTE8_ABGR_1555 {0}x{1}", this.width, this.height));
                break;

            case ABGR_1555:
                Debug.WriteLine(string.Format("Image ABGR_1555 {0}x{1}", this.width, this.height));
                this.LoadABGR1555(serialise);
                return;

            case RGBA_6666:
                Debug.WriteLine(string.Format("Image RGBA_6666 {0}x{1}", this.width, this.height));
                this.LoadRgba6666(serialise);
                return;

            case PALETTE8_RGB_888:
                Debug.WriteLine(string.Format("Image PALETTE8_RGB_888 {0}x{1}", this.width, this.height));
                this.Load256ColourPalettised(serialise);
                return;

            default:
                throw new FormatException(string.Format(CultureInfo.CurrentCulture, "Unknown image format 0x{0:x}", this.format));
            }
            data            = new byte[width * height * 3];
            format.OnPixel += SetPixelBySource;
            format.ReadData(serialise.Stream);
        }