📄 shiqian0197view.cpp
字号:
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if((p==lWidth-1)&&(q==lWidth-1))
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
||*(lpDIBBits+(lHeight-p)*lWidth+q)==0
// ||*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
// ||*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
||*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if(p>=1&&(p<=lHeight-2)&&(q==lWidth-1))
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
||*(lpDIBBits+(lHeight-p)*lWidth+q)==0
||*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
// ||*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
||*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if(p==0&&(q==lWidth-1))
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
// ||*(lpDIBBits+(lHeight-p)*lWidth+q)==0
||*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
/// ||*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
||*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if(p==0&&(q<=lWidth-2)&&q>=1)
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
// ||*(lpDIBBits+(lHeight-p)*lWidth+q)==0
||*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
||*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
||*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
else
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
||*(lpDIBBits+(lHeight-p)*lWidth+q)==0
||*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
||*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
||*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
}
memcpy(lpDIBBits, lpNewDIBBits, lLineBytes*lHeight);
LocalUnlock(hNewDIBBits);
LocalFree(hNewDIBBits);
InvalidateRect(NULL,TRUE);
}
void CShiqian0197View::OnXingtaiKaiyuansuan()
{
// TODO: Add your command handler code here
OnXingtaiFushiQuanfangwei();
OnXingtaiPengzhangQuanfangwei();
}
void CShiqian0197View::OnXingtaiBiyunsuan()
{
// TODO: Add your command handler code here
OnXingtaiPengzhangQuanfangwei();
OnXingtaiFushiQuanfangwei();
}
void CShiqian0197View::OnXingtaiPengzhangShuiping()
{
// TODO: Add your command handler code here
CShiqian0197Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
HDIB hDIB=pDoc->GetHDIB();
LPSTR lpDIB;
LPSTR lpDIBBits;
lpDIB = (char * ) ::GlobalLock((HGLOBAL) hDIB);
lpDIBBits = ::FindDIBBits(lpDIB);
long lWidth = ::DIBWidth(lpDIB);
long lLineBytes = WIDTHBYTES(lWidth * 8);
long lHeight = ::DIBHeight(lpDIB);
HDIB hNewDIBBits;
LPSTR lpNewDIBBits;
hNewDIBBits = (HDIB)LocalAlloc(LHND, lLineBytes*lHeight);
lpNewDIBBits = (char * )LocalLock(hNewDIBBits);
memcpy(lpNewDIBBits, lpDIBBits, lLineBytes *lHeight);
int p,q;
long n;
for( p=0;p<lHeight;p++)
for( q=0;q<lWidth;q++)
{
if(q==0)
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
else if(q==lWidth-1)
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
else
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
}
memcpy(lpDIBBits, lpNewDIBBits, lLineBytes*lHeight);
LocalUnlock(hNewDIBBits);
LocalFree(hNewDIBBits);
InvalidateRect(NULL,TRUE);
}
void CShiqian0197View::OnXingtaiPengzhangChuizhi()
{
// TODO: Add your command handler code here
CShiqian0197Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
HDIB hDIB=pDoc->GetHDIB();
LPSTR lpDIB;
LPSTR lpDIBBits;
lpDIB = (char * ) ::GlobalLock((HGLOBAL) hDIB);
lpDIBBits = ::FindDIBBits(lpDIB);
long lWidth = ::DIBWidth(lpDIB);
long lLineBytes = WIDTHBYTES(lWidth * 8);
long lHeight = ::DIBHeight(lpDIB);
HDIB hNewDIBBits;
LPSTR lpNewDIBBits;
hNewDIBBits = (HDIB)LocalAlloc(LHND, lLineBytes*lHeight);
lpNewDIBBits = (char * )LocalLock(hNewDIBBits);
memcpy(lpNewDIBBits, lpDIBBits, lLineBytes *lHeight);
int p,q;
long n;
for( p=0;p<lHeight;p++)
for( q=0;q<lWidth;q++)
{
if(p==0)
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
else if(p==lHeight)
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
else
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
}
memcpy(lpDIBBits, lpNewDIBBits, lLineBytes*lHeight);
LocalUnlock(hNewDIBBits);
LocalFree(hNewDIBBits);
InvalidateRect(NULL,TRUE);
}
void CShiqian0197View::OnXingtaiPengzhangQuanfangwei()
{
// TODO: Add your command handler code here
// OnXingtaiPengzhangChuizhi();
// OnXingtaiPengzhangShuiping();
CShiqian0197Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
HDIB hDIB=pDoc->GetHDIB();
LPSTR lpDIB;
LPSTR lpDIBBits;
lpDIB = (char * ) ::GlobalLock((HGLOBAL) hDIB);
lpDIBBits = ::FindDIBBits(lpDIB);
long lWidth = ::DIBWidth(lpDIB);
long lLineBytes = WIDTHBYTES(lWidth * 8);
long lHeight = ::DIBHeight(lpDIB);
HDIB hNewDIBBits;
LPSTR lpNewDIBBits;
hNewDIBBits = (HDIB)LocalAlloc(LHND, lLineBytes*lHeight);
lpNewDIBBits = (char * )LocalLock(hNewDIBBits);
memcpy(lpNewDIBBits, lpDIBBits, lLineBytes *lHeight);
int p,q;
long n;
for( p=0;p<lHeight;p++)
for( q=0;q<lWidth;q++)
{
if(p==0&&q==0)
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if(p>=1&&(p<=lHeight-2)&&q==0)
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if((p==lWidth-1)&&q==0)
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if((p==lWidth-1)&&q>=1&&(q<=lWidth-2))
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if((p==lWidth-1)&&(q==lWidth-1))
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if(p>=1&&(p<=lHeight-2)&&(q==lWidth-1))
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if(p==0&&(q==lWidth-1))
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
/// &&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
if(p==0&&(q<=lWidth-2)&&q>=1)
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
// &&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
else
{
if(
*(lpDIBBits+(lHeight-p-1)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-2)*lWidth+q)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q+1)==0
&&*(lpDIBBits+(lHeight-p-1)*lWidth+q-1)==0
)
n=0;
else
n=255;
*(lpNewDIBBits+(lHeight-p-1)*lWidth+q)=(unsigned char)n;
}
}
memcpy(lpDIBBits, lpNewDIBBits, lLineBytes*lHeight);
LocalUnlock(hNewDIBBits);
LocalFree(hNewDIBBits);
InvalidateRect(NULL,TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -