This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test code for rotating 1-bit and 4-bit Bitmap objects.
svn path=/trunk/winforms/; revision=52110
- Loading branch information
Jonathan Gilbert
committed
Oct 23, 2005
1 parent
6c8e178
commit 9c8c5bf
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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!"); | ||
} | ||
} |