void CMyDIPView::OnMenuitem32778()
{
// TODO: Add your command handler code here
int i,j;
unsigned char *lpSrc;
double c,r;
CMyDIPDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->m_hDIB == NULL)
return ;
LPSTR lpDIB = (LPSTR) ::GlobalLock((HGLOBAL) pDoc->m_hDIB);
LPSTR lpDIBBits=::FindDIBBits (lpDIB);
int cxDIB = (int) ::DIBWidth(lpDIB); // Size of DIB - x
int cyDIB = (int) ::DIBHeight(lpDIB); // Size of DIB - y
long lLineBytes = WIDTHBYTES(cxDIB * 8); // 计算图像每行的字节数
// 每行
r=2;
for(i = 0; i < cyDIB; i++)
{
// 每列
for(j = 0; j < cxDIB; j++)
{
// 指向DIB第i行,第j个象素的指针
lpSrc = (unsigned char*)lpDIBBits + lLineBytes * (cyDIB - 1 - i) + j;
// 计算新的灰度值
c=255/pow(255,r);
*(lpSrc) = BYTE(c*pow(*lpSrc,r));
}
}
::GlobalUnlock((HGLOBAL) pDoc->m_hDIB);
Invalidate(TRUE);
}
阅读(554) | 评论(0) | 转发(0) |