|
 |
|
ช่วยอธิบายโค้ดนี้หน่อยค่ะ พอดีกำลังตามหาโค้ดเกี่ยวกับ ImageProcessing พอดีไปเจอตัวอย่างอ่ะค่ะ |
|
 |
|
|
 |
 |
|
พอดีกำลังตามหาโค้ดเกี่ยวกับ ImageProcessing พอดีไปเจอตัวอย่างอ่ะค่ะ แต่ไม่ค่อยเข้าใจ ช่วยอะธิบายหน่อยนะคะ
Code (C#)
public static bool Brighten(Bitmap b, int nBrightness)
{
// GDI+ return format is BGR, NOT RGB.
BitmapData bmData
= b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;
unsafe
{
int nVal;
byte * p = (byte *)(void *)Scan0;
int nOffset = stride - b.Width*3;
int nWidth = b.Width * 3;
for(int y=0;y<b.Height;++y)
{
for (int x = 0; x < nWidth; ++x)
{
nVal = (int) (p[0] + nBrightness);
if (nVal < 0) nVal = 0;
if (nVal > 255) nVal = 255;
p[0] = (byte)nVal;
++p;
}
p += nOffset;
}
}
b.UnlockBits(bmData);
return true;
}
When you click on the Bright button this piece of code execute.
private void btnBright_Click(object sender, System.EventArgs e)
{
try
{
string path = Path.Combine(tv1.SelectedNode.FullPath, lstFiles.SelectedItem.ToString());
Bitmap b = new Bitmap(path);
Brighten(b, m_nTrack);
p2.Image = b;
}
catch{}
}
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-04-21 13:33:16 |
By :
Takezeed |
View :
1223 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สั้นๆ ง่ายๆ เป็นโค้ดที่ไว้สำหรับปรับรูปให้เป็นขาวดำน่ะ (ไม่ใช่ gray scale นะ ขาวดำจริงๆ)
|
 |
 |
 |
 |
Date :
2010-04-21 14:16:38 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|