Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FreeRDP/GdiTest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Moreau <marcandre.moreau@gmail.com>2011-03-29 21:02:06 +0400
committerMarc-André Moreau <marcandre.moreau@gmail.com>2011-03-29 21:02:06 +0400
commit7b58235a5a5deda53eeeb48290043bccc6d6b988 (patch)
treea084883472695ae701ab647e4a34814e7dc7239d
parente0b10317fbbde57c1fa0dba08464e2443c97e4e1 (diff)
improved pixel dump method
-rw-r--r--GdiTest/BitBltDrawingArea.cs11
-rw-r--r--GdiTest/LineToDrawingArea.cs19
-rw-r--r--GdiTest/MainWindow.cs2
-rw-r--r--GdiTest/TestDrawingArea.cs1
-rw-r--r--GdiTest/Win32GDI.cs6
5 files changed, 29 insertions, 10 deletions
diff --git a/GdiTest/BitBltDrawingArea.cs b/GdiTest/BitBltDrawingArea.cs
index 269f2f1..68f90f6 100644
--- a/GdiTest/BitBltDrawingArea.cs
+++ b/GdiTest/BitBltDrawingArea.cs
@@ -6,7 +6,9 @@ using System.Drawing;
namespace GdiTest
{
public class BitBltDrawingArea : TestDrawingArea
- {
+ {
+ String dumpText;
+
public BitBltDrawingArea ()
{
}
@@ -60,7 +62,7 @@ namespace GdiTest
{
for (int x = 0; x < 16; x++)
{
- System.Drawing.Color color = GDI_Win32.GetPixelColor(x, y);
+ System.Drawing.Color color = GDI_Win32.GetPixelColor(hdc, x, y);
text += String.Format("0x{0:X}, ", color.ToArgb());
}
text += "\n";
@@ -69,6 +71,11 @@ namespace GdiTest
return text;
}
+
+ public override String getDumpText ()
+ {
+ return dumpText;
+ }
}
}
diff --git a/GdiTest/LineToDrawingArea.cs b/GdiTest/LineToDrawingArea.cs
index 0144258..1e78aff 100644
--- a/GdiTest/LineToDrawingArea.cs
+++ b/GdiTest/LineToDrawingArea.cs
@@ -15,6 +15,7 @@ namespace GdiTest
}
private bool rendered;
+ private String dumpText;
public LineToDrawingArea()
{
@@ -174,6 +175,9 @@ namespace GdiTest
}
}
}
+
+ dumpText = this.dump();
+
return true;
}
@@ -182,7 +186,7 @@ namespace GdiTest
String text = "";
Win32GDI GDI_Win32 = Win32GDI.getInstance();
-
+
if (GDI_Win32.isAvailable())
{
System.Drawing.Graphics wg = Gtk.DotNet.Graphics.FromDrawable(this.GdkWindow, true);
@@ -192,8 +196,12 @@ namespace GdiTest
{
for (int x = 0; x < 16; x++)
{
- System.Drawing.Color color = GDI_Win32.GetPixelColor(x, y);
- text += String.Format("0x{0:X}, ", color.ToArgb());
+ System.Drawing.Color color = GDI_Win32.GetPixelColor(hdc, x, y);
+
+ if (color.R == 255)
+ text += "0xFF, ";
+ else
+ text += "0x00, ";
}
text += "\n";
}
@@ -201,6 +209,11 @@ namespace GdiTest
return text;
}
+
+ public override String getDumpText()
+ {
+ return dumpText;
+ }
}
}
diff --git a/GdiTest/MainWindow.cs b/GdiTest/MainWindow.cs
index 214c593..e422090 100644
--- a/GdiTest/MainWindow.cs
+++ b/GdiTest/MainWindow.cs
@@ -52,7 +52,7 @@ public partial class MainWindow : Gtk.Window
}
protected virtual void OnDumpButtonClicked (object sender, System.EventArgs e)
{
- String dumpText = testDrawingArea.dump();
+ String dumpText = testDrawingArea.getDumpText();
dumpTextView.Buffer.Text = dumpText;
}
diff --git a/GdiTest/TestDrawingArea.cs b/GdiTest/TestDrawingArea.cs
index 27e9d24..ecc5d61 100644
--- a/GdiTest/TestDrawingArea.cs
+++ b/GdiTest/TestDrawingArea.cs
@@ -11,6 +11,7 @@ namespace GdiTest
}
abstract public String dump();
+ abstract public String getDumpText();
}
}
diff --git a/GdiTest/Win32GDI.cs b/GdiTest/Win32GDI.cs
index 389e48e..1d1c722 100644
--- a/GdiTest/Win32GDI.cs
+++ b/GdiTest/Win32GDI.cs
@@ -132,11 +132,9 @@ namespace GdiTest
return 0;
}
- public System.Drawing.Color GetPixelColor(int x, int y)
+ public System.Drawing.Color GetPixelColor(IntPtr hdc, int X, int Y)
{
- IntPtr hdc = GetDC(IntPtr.Zero);
- uint pixel = Callbacks.GetPixel(hdc, x, y);
- ReleaseDC(IntPtr.Zero, hdc);
+ uint pixel = Callbacks.GetPixel(hdc, X, Y);
System.Drawing.Color color = System.Drawing.Color.FromArgb((int)(pixel & 0x000000FF),
(int)(pixel & 0x0000FF00) >> 8,
(int)(pixel & 0x00FF0000) >> 16);