Пример #1
0
        public static void Copy(Bitmap source, Rectangle sourceRect, UnsafeBitmap output, Rectangle destRect)
        {
            Graphics g = Graphics.FromImage(output.Bitmap);

            g.DrawImage(source, destRect, sourceRect, GraphicsUnit.Pixel);
            g.Dispose();
        }
Пример #2
0
        /// <summary>
        /// Once the arranging is complete, copies the bitmap data for each
        /// bitmap to its chosen position in the single larger output bitmap.
        /// </summary>
        static UnsafeBitmap CopyBitmapsToOutput(List <ArrangedBitmap> bitmaps,
                                                Dictionary <uint, Bitmap> sourceBitmaps,
                                                Dictionary <uint, Rectangle> outputBitmaps,
                                                int width, int height)
        {
            UnsafeBitmap output = new UnsafeBitmap(width, height);

            foreach (ArrangedBitmap bitmap in bitmaps)
            {
                Bitmap source = sourceBitmaps[bitmap.Id];

                int x = bitmap.X;
                int y = bitmap.Y;

                int w = source.Width;
                int h = source.Height;

                // Copy the main bitmap data to the output sheet.
                UnsafeBitmap.Copy(source, new Rectangle(0, 0, w, h),
                                  output, new Rectangle(x + 1, y + 1, w, h));

                // Copy a border strip from each edge of the bitmap, creating
                // a one pixel padding area to avoid filtering problems if the
                // bitmap is scaled or rotated.
                UnsafeBitmap.Copy(source, new Rectangle(0, 0, 1, h),
                                  output, new Rectangle(x, y + 1, 1, h));

                UnsafeBitmap.Copy(source, new Rectangle(w - 1, 0, 1, h),
                                  output, new Rectangle(x + w + 1, y + 1, 1, h));

                UnsafeBitmap.Copy(source, new Rectangle(0, 0, w, 1),
                                  output, new Rectangle(x + 1, y, w, 1));

                UnsafeBitmap.Copy(source, new Rectangle(0, h - 1, w, 1),
                                  output, new Rectangle(x + 1, y + h + 1, w, 1));

                // Copy a single pixel from each corner of the bitmap,
                // filling in the corners of the one pixel padding area.
                UnsafeBitmap.Copy(source, new Rectangle(0, 0, 1, 1),
                                  output, new Rectangle(x, y, 1, 1));

                UnsafeBitmap.Copy(source, new Rectangle(w - 1, 0, 1, 1),
                                  output, new Rectangle(x + w + 1, y, 1, 1));

                UnsafeBitmap.Copy(source, new Rectangle(0, h - 1, 1, 1),
                                  output, new Rectangle(x, y + h + 1, 1, 1));

                UnsafeBitmap.Copy(source, new Rectangle(w - 1, h - 1, 1, 1),
                                  output, new Rectangle(x + w + 1, y + h + 1, 1, 1));

                // Remember where we placed this bitmap.
                outputBitmaps.Add(bitmap.Id, new Rectangle(x + 1, y + 1, w, h));
            }

            return(output);
        }
Пример #3
0
 public void Convert(SwfCompilationUnit swf, UnsafeBitmap fullBitmap, Dictionary<uint, System.Drawing.Rectangle> rects)
 {
     this.swf = swf;
     this.fullBitmap = fullBitmap;
     this.rects = rects;
     foreach(ISwfTag tag in swf.Tags)
     {
         this.ParseTag(tag);
     }
 }
Пример #4
0
 public void Convert(SwfCompilationUnit swf, UnsafeBitmap fullBitmap, Dictionary <uint, System.Drawing.Rectangle> rects)
 {
     this.swf        = swf;
     this.fullBitmap = fullBitmap;
     this.rects      = rects;
     foreach (ISwfTag tag in swf.Tags)
     {
         this.ParseTag(tag);
     }
 }
Пример #5
0
        /// <summary>
        /// Once the arranging is complete, copies the bitmap data for each
        /// bitmap to its chosen position in the single larger output bitmap.
        /// </summary>
        static UnsafeBitmap CopyBitmapsToOutput(List<ArrangedBitmap> bitmaps,
                                                 IList<Bitmap> sourceBitmaps,
                                                 Dictionary<uint, Rectangle> outputBitmaps,
                                                 int width, int height)
        {
            UnsafeBitmap output = new UnsafeBitmap(width, height);

            foreach (ArrangedBitmap bitmap in bitmaps)
            {
                Bitmap source = sourceBitmaps[bitmap.Index];

                int x = bitmap.X;
                int y = bitmap.Y;

                int w = source.Width;
                int h = source.Height;

                // Copy the main bitmap data to the output sheet.
                UnsafeBitmap.Copy(source, new Rectangle(0, 0, w, h),
                                   output, new Rectangle(x + 1, y + 1, w, h));

                // Copy a border strip from each edge of the bitmap, creating
                // a one pixel padding area to avoid filtering problems if the
                // bitmap is scaled or rotated.
                UnsafeBitmap.Copy(source, new Rectangle(0, 0, 1, h),
                                   output, new Rectangle(x, y + 1, 1, h));

                UnsafeBitmap.Copy(source, new Rectangle(w - 1, 0, 1, h),
                                   output, new Rectangle(x + w + 1, y + 1, 1, h));

                UnsafeBitmap.Copy(source, new Rectangle(0, 0, w, 1),
                                   output, new Rectangle(x + 1, y, w, 1));

                UnsafeBitmap.Copy(source, new Rectangle(0, h - 1, w, 1),
                                   output, new Rectangle(x + 1, y + h + 1, w, 1));

                // Copy a single pixel from each corner of the bitmap,
                // filling in the corners of the one pixel padding area.
                UnsafeBitmap.Copy(source, new Rectangle(0, 0, 1, 1),
                                   output, new Rectangle(x, y, 1, 1));

                UnsafeBitmap.Copy(source, new Rectangle(w - 1, 0, 1, 1),
                                   output, new Rectangle(x + w + 1, y, 1, 1));

                UnsafeBitmap.Copy(source, new Rectangle(0, h - 1, 1, 1),
                                   output, new Rectangle(x, y + h + 1, 1, 1));

                UnsafeBitmap.Copy(source, new Rectangle(w - 1, h - 1, 1, 1),
                                   output, new Rectangle(x + w + 1, y + h + 1, 1, 1));

                // Remember where we placed this bitmap.
                outputBitmaps.Add(bitmap.Id, new Rectangle(x + 1, y + 1, w, h));
            }

            return output;
        }
Пример #6
0
 public static void Copy(Bitmap source, Rectangle sourceRect, UnsafeBitmap output,  Rectangle destRect)
 {
     Graphics g = Graphics.FromImage(output.Bitmap);
     g.DrawImage(source, destRect, sourceRect, GraphicsUnit.Pixel);
     g.Dispose();
 }