Ejemplo n.º 1
0
        internal void Write(BinaryWriter bw)
        {
            // 1. Bitmap
            SerializationHelper.WriteImage(bw, BitmapDataInfo.BackingImage);

            // 2. Data
            BitmapData data = BitmapDataInfo.BitmapData;

            bw.Write(data.Width);
            bw.Write(data.Height);
            bw.Write(data.Stride);
            bw.Write((int)data.PixelFormat);
        }
Ejemplo n.º 2
0
        internal void Write(BinaryWriter bw)
        {
            // 1. Image type
            bw.Write((byte)ImageInfo.Type);
            if (ImageInfo.Type == ImageInfoType.None)
            {
                return;
            }

            // 2. How multi-frame image is saved
            bool saveAsSingleImage = ImageInfo.Type.In(ImageInfoType.SingleImage, ImageInfoType.Icon) || ForceSaveCompoundImage();

            if (ImageInfo.Type != ImageInfoType.SingleImage)
            {
                bw.Write(saveAsSingleImage);
            }

            // 3. Main image (if any)
            if (saveAsSingleImage)
            {
                if (ImageInfo.Type == ImageInfoType.Icon)
                {
                    SerializationHelper.WriteIcon(bw, ImageInfo.GetCreateIcon());
                }
                else
                {
                    SerializationHelper.WriteImage(bw, ImageInfo.GetCreateImage());
                }
            }

            // Meta is saved even for pages so we will have a general size, etc.
            WriteMeta(bw, ImageInfo);

            // 4. Frames (if any)
            if (ImageInfo.HasFrames)
            {
                bw.Write(ImageInfo.Frames.Length);
                foreach (ImageFrameInfo frame in ImageInfo.Frames)
                {
                    if (!saveAsSingleImage)
                    {
                        SerializationHelper.WriteImage(bw, frame.Image);
                    }
                    WriteMeta(bw, frame);
                    if (ImageInfo.Type == ImageInfoType.Animation)
                    {
                        bw.Write(frame.Duration);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        internal void Write(BinaryWriter bw)
        {
            // 1. Bitmap
            SerializationHelper.WriteImage(bw, GraphicsInfo.GraphicsImage);

            // 2. Transformation matrix
            BinarySerializer.SerializeByWriter(bw, GraphicsInfo.Transform.Elements);

            // 3. Meta
            bw.Write(GraphicsInfo.OriginalVisibleClipBounds.X);
            bw.Write(GraphicsInfo.OriginalVisibleClipBounds.Y);
            bw.Write(GraphicsInfo.OriginalVisibleClipBounds.Width);
            bw.Write(GraphicsInfo.OriginalVisibleClipBounds.Height);
            bw.Write(GraphicsInfo.TransformedVisibleClipBounds.X);
            bw.Write(GraphicsInfo.TransformedVisibleClipBounds.Y);
            bw.Write(GraphicsInfo.TransformedVisibleClipBounds.Width);
            bw.Write(GraphicsInfo.TransformedVisibleClipBounds.Height);
            bw.Write((int)GraphicsInfo.PageUnit);
            bw.Write(GraphicsInfo.Resolution.X);
            bw.Write(GraphicsInfo.Resolution.Y);
        }