Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Test code for rotating 1-bit and 4-bit Bitmap objects.
Browse files Browse the repository at this point in the history
svn path=/trunk/winforms/; revision=52110
  • Loading branch information
Jonathan Gilbert committed Oct 23, 2005
1 parent 6c8e178 commit 9c8c5bf
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
Binary file added rotate1bit4bit/1bit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rotate1bit4bit/4bit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions rotate1bit4bit/Makefile
@@ -0,0 +1,12 @@
all: test

test: clean test.exe
mono test.exe

test.exe: test.cs
mcs test.cs -r:System.Drawing

clean:
rm -f test.exe *_Rotate*.png

.PHONY: all test clean
64 changes: 64 additions & 0 deletions rotate1bit4bit/test.cs
@@ -0,0 +1,64 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

class Test
{
static Bitmap load(string name)
{
using (Stream stream = new FileStream(name, FileMode.Open, FileAccess.Read, FileShare.None))
return (Bitmap)Bitmap.FromStream(stream);
}

static void Main()
{
foreach (string type_name in Enum.GetNames(typeof(RotateFlipType)))
{
RotateFlipType type = (RotateFlipType)Enum.Parse(typeof(RotateFlipType), type_name);

if (type_name != type.ToString())
Console.WriteLine("- processing {0} ({1})...", type_name, type);
else
Console.WriteLine("- processing {0}...", type_name);

Bitmap result = null;

try
{
result = load("1bit.png");
result.RotateFlip(type);
}
catch (Exception e)
{
Console.WriteLine("EXCEPTION: {0}: {1}", e.GetType().Name, e.Message);
if (result != null) try { result.Dispose(); } catch {}
result = null;
}

if (result != null)
result.Save("1bit_" + type_name + ".png", ImageFormat.Png);

try { result.Dispose(); } catch {}

try
{
result = load("4bit.png");
result.RotateFlip(type);
}
catch (Exception e)
{
Console.WriteLine("EXCEPTION: {0}: {1}", e.GetType().Name, e.Message);
if (result != null) try { result.Dispose(); } catch {}
result = null;
}

if (result != null)
result.Save("4bit_" + type_name + ".png", ImageFormat.Png);

try { result.Dispose(); } catch {}
}

Console.WriteLine("done!");
}
}

0 comments on commit 9c8c5bf

Please sign in to comment.