Esempio n. 1
0
        public void TextureHandler_Bmp_CombineFailed()
        {
            TextureHandler target = new TextureHandler(32, 32);

            Bitmap input1 = new Bitmap(Path.Combine(localFolder, image_bmp_1_big_red));
            Bitmap input2 = new Bitmap(Path.Combine(localFolder, image_bmp_1_big_black));
            Bitmap input3 = new Bitmap(Path.Combine(localFolder, image_bmp_1_big_red));
            Bitmap input4 = new Bitmap(Path.Combine(localFolder, image_bmp_1_big_green));

            Bitmap[][] inputArray = new Bitmap[2][];
            inputArray[0] = new Bitmap[2] {
                input1, input2
            };
            inputArray[1] = new Bitmap[2] {
                input3, input4
            };

            target.Combine(inputArray, 32, 32, true);
            target.Save(Path.Combine(localFolder, image_bmp_1_combineFail_out), ImageFormat.Bmp);
            target.Dispose();

            Bitmap original = new Bitmap(Path.Combine(localFolder, image_bmp_1_big));
            Bitmap output   = new Bitmap(Path.Combine(localFolder, image_bmp_1_combineFail_out));

            BitmapAssert.AreNotEqual(original, output, 10, "Written image should not be like the reference.");

            // cleanup - dispose of the bitmaps
            original.Dispose();
            output.Dispose();
            input1.Dispose();
            input2.Dispose();
            input3.Dispose();
            input4.Dispose();
        }
Esempio n. 2
0
        public void TextureHandler_Bmp_ReadWrite()
        {
            TextureHandler t1 = new TextureHandler(Path.Combine(localFolder, image_bmp_1));

            t1.Save(Path.Combine(localFolder, image_bmp_1_out), ImageFormat.Bmp);
            t1.Dispose();

            Bitmap original = new Bitmap(Path.Combine(localFolder, image_bmp_1));
            Bitmap output   = new Bitmap(Path.Combine(localFolder, image_bmp_1_out));

            BitmapAssert.AreEqual(original, output, 2, "Written image should be as the original.");

            // cleanup - dispose of the bitmaps
            original.Dispose();
            output.Dispose();
        }
Esempio n. 3
0
        public void TextureHandler_Bmp_ResizeDown()
        {
            TextureHandler t1 = new TextureHandler(Path.Combine(localFolder, image_bmp_1));

            t1.Resize(8, 8, true);
            t1.Save(Path.Combine(localFolder, image_bmp_1_small_out), ImageFormat.Bmp);
            t1.Dispose();

            Bitmap original = new Bitmap(Path.Combine(localFolder, image_bmp_1_small));
            Bitmap output   = new Bitmap(Path.Combine(localFolder, image_bmp_1_small_out));

            BitmapAssert.AreEqual(original, output, 128, "Written image should be like the reference.");

            // cleanup - dispose of the bitmaps
            original.Dispose();
            output.Dispose();
        }
Esempio n. 4
0
        public void TextureHandler_Bmp_ResizeUp()
        {
            // RL: This is a stress test, if it doesn't pass, it's not the end of the world as
            // most video card/driver will handle the upscaling very differently.
            TextureHandler t1 = new TextureHandler(Path.Combine(localFolder, image_bmp_1));

            t1.Resize(32, 32, true);
            t1.Save(Path.Combine(localFolder, image_bmp_1_big_out), ImageFormat.Bmp);
            t1.Dispose();

            Bitmap original = new Bitmap(Path.Combine(localFolder, image_bmp_1_big));
            Bitmap output   = new Bitmap(Path.Combine(localFolder, image_bmp_1_big_out));

            BitmapAssert.AreEqual(original, output, 200, "Written image should be like the reference.");

            // cleanup - dispose of the bitmaps
            original.Dispose();
            output.Dispose();
        }
Esempio n. 5
0
        private bool processImages()
        {
            this.Log().Debug("Processing the final image");
            MessageDialog result;

            // missing a target filename, return
            if (txtFilename.Text.Trim() == "")
            {
                this.Log().Warn("Target Filename empty. Abort!");
                result = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Output filename cannot be empty");
                if (result.Run() == (int)ResponseType.Ok)
                {
                    result.Destroy();
                }
                return(false);
            }

            this.Log().Info("Fetching the bitmaps");
            Bitmap[][] inputArray = FetchImages();

            // initialize
            this.Log().Info("Generation of the target bitmap");
            TextureHandler output = new TextureHandler(currentPrefs.width, currentPrefs.height);

            output.Combine(inputArray, currentPrefs.keepProportion);
            string finalImage = System.IO.Path.Combine(currentPath, txtFilename.Text + lblExtension.Text);

            output.Save(finalImage);

            output.Dispose();

            this.Log().Info("Output successful");
            result = new MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, "Output successful");
            if (result.Run() == (int)ResponseType.Ok)
            {
                result.Destroy();
            }

            return(false);
        }