Xleniz
06-13-2013, 10:42 PM
I made a "SUPER" pixel reader :[
Pros:
It can detect positions 1, position 2, position 3, and play song for each position
Cons:
It takes 0.2 to read pixel, which means, if you run fast, you wont get music.
So my question is: How to do pixelreading in fastest way, C#?
(( Im Doing bitblt right now, its faster than both lockbits and bmp getpixel ))
I found an UNSAFE Code, but I cannot get it to work:
static Color[] GetPixelColumnFast(Bitmap bmp, int x)
{
Color[] pixelColumn = new Color[bmp.Height];
BitmapData pixelData = bmp.LockBits(
new Rectangle(0, 0, bmp.Width, bmp.Height),
ImageLockMode.ReadOnly,
PixelFormat.Format32bppArgb);
unsafe
{
int* pData = (int*)pixelData.Scan0.ToPointer();
pData += x;
for (int i = 0; i < bmp.Height; ++i)
{
pixelColumn[i] = Color.FromArgb(*pData);
pData += bmp.Width;
}
}
bmp.UnlockBits(pixelData);
return pixelColumn;
}
THNX
++++ If theres a better way to detect pixels, like, minimap and compare with (?), tell me pliz.
Pros:
It can detect positions 1, position 2, position 3, and play song for each position
Cons:
It takes 0.2 to read pixel, which means, if you run fast, you wont get music.
So my question is: How to do pixelreading in fastest way, C#?
(( Im Doing bitblt right now, its faster than both lockbits and bmp getpixel ))
I found an UNSAFE Code, but I cannot get it to work:
static Color[] GetPixelColumnFast(Bitmap bmp, int x)
{
Color[] pixelColumn = new Color[bmp.Height];
BitmapData pixelData = bmp.LockBits(
new Rectangle(0, 0, bmp.Width, bmp.Height),
ImageLockMode.ReadOnly,
PixelFormat.Format32bppArgb);
unsafe
{
int* pData = (int*)pixelData.Scan0.ToPointer();
pData += x;
for (int i = 0; i < bmp.Height; ++i)
{
pixelColumn[i] = Color.FromArgb(*pData);
pData += bmp.Width;
}
}
bmp.UnlockBits(pixelData);
return pixelColumn;
}
THNX
++++ If theres a better way to detect pixels, like, minimap and compare with (?), tell me pliz.