Beispiel #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();
        }
        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);
        }