You are not logged in.
Dear visitor, welcome to Aqua Computer Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

TrOuble
God






|
|
Source code |
1 2 3 4 5 6 7 8 9 10 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using System.Drawing.Imaging; using System.Diagnostics; |
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
Stopwatch sw = new Stopwatch();
Bitmap Screenshot;
Graphics gfx;
Color pixelColor;
string color,R,G,B;
int position = 0;
int tempInt = 0;
string[,] hexArray = new string[Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height];
sw.Start();
Screenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
gfx = Graphics.FromImage(Screenshot);
gfx.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
for (int i = 0; i < Screen.PrimaryScreen.Bounds.Width; i++)
{
for (int j = 0; j < Screen.PrimaryScreen.Bounds.Height; j++)
{
//pixel detection
pixelColor = Screenshot.GetPixel(i, j);
color = pixelColor.ToString();
//format ist: "Color [A=XXX, R=XXX, G=XXX, B=XXX]"
//"Color [A=XXX, R=" löschen
position = color.IndexOf(",");
color = color.Substring(position + 4);
//ende des R werts bestimmen
position = color.IndexOf(",");
R = color.Substring(0, position);
//"XXX, G=" löschen & ende bestimmen
color = color.Substring(position + 4);
position = color.IndexOf(",");
G = color.Substring(0, position);
//"XXX, B=" löschen & ende bestimmen
color = color.Substring(position + 4);
position = color.IndexOf("]");
B = color.Substring(0, position);
//rgb werte in hex werte ändern
tempInt = Convert.ToInt32(R);
R = String.Format("{0:X}", tempInt);
tempInt = Convert.ToInt32(G);
G = String.Format("{0:X}", tempInt);
tempInt = Convert.ToInt32(B);
B = String.Format("{0:X}", tempInt);
//bei zahlen unter 16 ist zbsp 10 = A und nicht 0A, daher 0 drankleben
if (R.Length == 1)
R = "0" + R;
if (G.Length == 1)
G = "0" + G;
if (B.Length == 1)
B = "0" + B;
hexArray[i,j] = R + G + B;
}
}
sw.Stop();
MessageBox.Show("Das Einlesen von " + (Screen.PrimaryScreen.Bounds.Width * Screen.PrimaryScreen.Bounds.Height)
+ " Pixeln hat " + sw.ElapsedMilliseconds + "ms gedauert. Das sind " +
(Screen.PrimaryScreen.Bounds.Width * Screen.PrimaryScreen.Bounds.Height / sw.ElapsedMilliseconds)
+ " Pixel/ms.");
|

|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
color = pixelColor.ToString();
//format ist: "Color [A=XXX, R=XXX, G=XXX, B=XXX]"
//"Color [A=XXX, R=" löschen
position = color.IndexOf(",");
color = color.Substring(position + 4);
//ende des R werts bestimmen
position = color.IndexOf(",");
R = color.Substring(0, position);
//"XXX, G=" löschen & ende bestimmen
color = color.Substring(position + 4);
position = color.IndexOf(",");
G = color.Substring(0, position);
//"XXX, B=" löschen & ende bestimmen
color = color.Substring(position + 4);
position = color.IndexOf("]");
B = color.Substring(0, position);
|



)
-