Beispiel #1
0
        /// <summary>
        /// Slices the tileset's tiles down to 128x256px,
        /// and returns the sliced off tiles.
        /// </summary>
        /// <returns>The sliced off tiles</returns>
        public Bitmap SliceTilesImage()
        {
            Bitmap slice;

            tilesImage = BitmapEditor.SliceTiles(tilesImage, out slice);
            return(slice);
        }
        private void treeViewResources_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //  Get the editor host.
            var editorHost = tableLayoutPanel1.GetControlFromPosition(1, 1);

            //  Release any existing editor.
            if (currentEditor != null)
            {
                editorHost.Controls.Remove((Control)currentEditor);
                currentEditor.Release();
            }

            //  Create the appropriate control.
            var resource = e.Node?.Tag as Win32Resource;

            if (resource == null)
            {
                return;
            }

            if (resource.ResourceType.IsKnownResourceType(ResType.RT_BITMAP))
            {
                var bitmapEditor = new BitmapEditor {
                    Dock = DockStyle.Fill
                };
                currentEditor = bitmapEditor;
                var parent = tableLayoutPanel1.GetControlFromPosition(1, 1);
                parent.Controls.Add(bitmapEditor);
                bitmapEditor.Initialise(resource);
            }
            else if (resource.ResourceType.IsKnownResourceType(ResType.RT_ICON))
            {
                var iconEditor = new IconEditor {
                    Dock = DockStyle.Fill
                };
                currentEditor = iconEditor;
                var parent = tableLayoutPanel1.GetControlFromPosition(1, 1);
                parent.Controls.Add(iconEditor);
                iconEditor.Initialise(resource);
            }
        }
Beispiel #3
0
        public void BitmapEditor_GetPaintValueSupported_Invoke_ReturnsTrue(ITypeDescriptorContext context)
        {
            var editor = new BitmapEditor();

            Assert.True(editor.GetPaintValueSupported(context));
        }
Beispiel #4
0
        public void BitmapEditor_GetEditStyle_Invoke_ReturnsModal(ITypeDescriptorContext context)
        {
            var editor = new BitmapEditor();

            Assert.Equal(UITypeEditorEditStyle.Modal, editor.GetEditStyle(context));
        }
Beispiel #5
0
        public void BitmapEditor_Ctor_Default()
        {
            var editor = new BitmapEditor();

            Assert.False(editor.IsDropDownResizable);
        }
Beispiel #6
0
 public void StitchTilesImage(Bitmap slicedImage)
 {
     this.tilesImage = BitmapEditor.StitchTiles(slicedImage, this.tilesImage);
 }
Beispiel #7
0
        static void Main(string[] args)
        {
            Stopwatch stopwatch = new Stopwatch();

            Bitmap a = new Bitmap("./images/A.png");
            Bitmap b = new Bitmap("./images/B.png");
            Bitmap c = new Bitmap("./images/C.png");
            Bitmap d = new Bitmap("./images/D.png");
            Bitmap e = new Bitmap("./images/D.png");


            // Test cases enabling
            bool testBitmapEditor          = true;
            bool testBitmapDifference      = true;
            bool testBitmapComparator      = true;
            bool testBitmapBatchComparator = true;
            bool testIntegration           = true;


            // CLASS BitmapEditor
            if (testBitmapEditor)
            {
                // BitmapEditor.SetPixel()
                // Bitmap <-> BitmapEditor implicit conversions
                {
                    Bitmap       bitmap       = new Bitmap(4, 4, PixelFormat.Format24bppRgb);
                    BitmapEditor bitmapEditor = bitmap;
                    bitmapEditor.SetPixel(0, 0, Color.Cyan);
                    bitmapEditor.SetPixel(1, 1, Color.Cyan);
                    bitmapEditor.SetPixel(2, 2, Color.Cyan);
                    bitmap = bitmapEditor;
                    bitmap.Save("./bitmapEditorConversions1.png");
                }


                // BitmapEditor.SetPixel()
                // Bitmap <-> BitmapEditor explicit conversions
                {
                    BitmapEditor bitmapEditor = new BitmapEditor(new Bitmap(a));
                    bitmapEditor.SetPixel(0, 0, Color.Cyan);
                    bitmapEditor.SetPixel(1, 1, Color.Cyan);
                    bitmapEditor.SetPixel(2, 2, Color.Cyan);
                    bitmapEditor.SetPixel(3, 3, Color.Cyan);
                    bitmapEditor.SetPixel(4, 4, Color.Cyan);
                    bitmapEditor.SetPixel(5, 5, Color.Cyan);
                    bitmapEditor.SetPixel(6, 6, Color.Cyan);
                    bitmapEditor.SetPixel(100, 100, Color.Cyan);
                    bitmapEditor.SetPixel(101, 100, Color.Cyan);
                    bitmapEditor.SetPixel(102, 100, Color.Cyan);
                    bitmapEditor.SetPixel(103, 100, Color.Cyan);
                    ((Bitmap)(bitmapEditor)).Save("./bitmapEditorConversions2.png");
                }
            }


            // CLASS BitmapDifference TEST
            if (testBitmapDifference)
            {
                {
                    // BitmapDifference from Bitmap
                    // BitmapDifference.SetPixel() - marking pixels as different
                    // BitmapDifference.GetBitmapDifferenceImage

                    BitmapDifference bitmapDifferenceA = new BitmapDifference(a);
                    bitmapDifferenceA.SetPixel(100, 100, true);
                    bitmapDifferenceA.SetPixel(100, 101, true);
                    bitmapDifferenceA.SetPixel(100, 102, true);
                    bitmapDifferenceA.SetPixel(100, 103, true);
                    bitmapDifferenceA.GetBitmapDifferenceImage().Save("./bitmapDifferenceImage.png");


                    // BitmapDifference from Bitmap
                    // BitmapDifference.AddMask()
                    // BitmapDifference.GetBitmapMaskedImage()

                    BitmapDifference bitmapDifferenceB = new BitmapDifference(a);
                    bitmapDifferenceB.AddMask(bitmapDifferenceA.GetBitmapDifferenceImage());
                    bitmapDifferenceB.GetBitmapMaskedImage().Save("./bitmapDifferenceMaskedImage.png");
                }
            }


            // CLASS BitmapComparator TEST
            if (testBitmapComparator)
            {
                BitmapComparator bitmapComparator = new BitmapComparator(a, b);
                bitmapComparator.GetBitmapDifferenceImage().Save("./bitmapComparatorDiffImg.png");
            }


            // CLASS BitmapBatchComparator TEST
            if (testBitmapBatchComparator)
            {
                BitmapBatch bitmapBatch = new BitmapBatch();
                bitmapBatch.Add(a);
                bitmapBatch.Add(b);
                bitmapBatch.Add(c);
                bitmapBatch.Add(d);
                bitmapBatch.Add(e);
                BitmapBatchComparator bitmapBatchComparator = new BitmapBatchComparator(bitmapBatch);
                bitmapBatchComparator.GetBitmapDifferenceImage().Save("./bitmapBatchComparatorDiffImg.png");
            }


            // CLASS integration TEST
            if (testIntegration)
            {
                stopwatch.Restart();

                BitmapBatch bbb = new BitmapBatch();

                Console.WriteLine("A: " + stopwatch.ElapsedMilliseconds);

                bbb = Screener.GetScreenshotBatch(3000, 250);

                Console.WriteLine("B: " + stopwatch.ElapsedMilliseconds);

                BitmapBatchComparator bbcb = new BitmapBatchComparator(bbb);

                Console.WriteLine("C: " + stopwatch.ElapsedMilliseconds);

                bbcb.GetBitmapDifferenceImage().Save("./bitmapBatchDifference.png");

                Console.WriteLine("D: " + stopwatch.ElapsedMilliseconds);

                BitmapComparator ndnjjcd = new BitmapComparator(a, b);

                Console.WriteLine("E: " + stopwatch.ElapsedMilliseconds);
            }

            Console.WriteLine("Done.");
            Console.ReadKey();
        }