鼠标右键调节BMP图片亮度对比度。
代码说明:
通过鼠标右键来调节图片的亮度和对比度。里面有扫描仪程序代码。调节对比度,亮度的代码很简单。来源于网站VOID CScanToDocDlg::BrightAndContrast(HBITMAP hBitmap, INT bright, INT contrast, BYTE threshold){ FLOAT cv = contrast 0 && contrast < 255) cv = 1.0f / (1.0f - cv) - 1.0f; BYTE values[256]; for (INT i = 0; i < 256; i ++) { INT v = contrast > 0? CheckValue(i + bright) : i; if (contrast >= 255) v = v >= threshold? 255 : 0; else v = CheckValue(v + (INT)((v - threshold) * cv + 0.5f)); values[i] = contrast < 0? CheckValue(v + bright) : v; } BITMAP bm; GetObject(hBitmap, sizeof(BITMAP), &bm ); LPARGBQuad o,p; for (UINT y = 0; y < bm.bmHeight; y ++, p+=nRowPadding, o+=nRowPadding) {
下载说明:请别用迅雷下载,失败请重下,重下不扣分!