📄 wltview.cpp
字号:
FW** p0=new FW* [bh];
for(int i=0;i<bh;i++)
{
p0[i]=new FW [bw];
}
for(int k=0;k<3;k++)
{
for(int m=0;m<bh;m++)
for(int n=0;n<bw;n++)
{
p0[m][n]=*(pW+3*(bw*m+n)+k);
}
//resN(p0,bh,bw,N);
iflwt2D(p0,bh,bw,N);
for(m=0;m<height_s;m++)
for(int n=0;n<width_s;n++)
{
if(p0[m][n]>255)*(pBitmapData+3*(width_s*m+n)+k)=255;
else if(p0[m][n]<0)*(pBitmapData+3*(width_s*m+n)+k)=0;
else *(pBitmapData+3*(width_s*m+n)+k)=p0[m][n];
}
}
for(i=0;i<bh;i++)
{
delete p0[i];
}
delete p0;
OP=1;
CDC* pDC=GetDC();
OnDraw(pDC);
}
else
{
MessageBox("尚未进行小波变换,请先进行小波变换!");
}
}
void CWltView::OnSetDecoderD()
{
// TODO: Add your command handler code here
if(OP==3)
{
InputDlen_Dialog dd;
if(dd.DoModal()==IDOK)
{
int bh=height;
int bw=width;
int s=scale;
dlenr=dd.m_dlenr;
char* c;
int l;
FW** p0=new FW* [bh];
for(int i=0;i<bh;i++)
{
p0[i]=new FW [bw];
}
for(int k=0;k<3;k++)
{
if(k==0)
{
c=rcs;
l=rcs_L;
}
else if(k==1)
{
c=gcs;
l=gcs_L;
}
else
{
c=bcs;
l=bcs_L;
}
if(CODER==2)SPIHT_decoder(p0,bh,bw,scale,c,l*dlenr,TN);
else EZW_decoder(p0,bh,bw,scale,c,l*dlenr,TN);
iflwt2D(p0,bh,bw,scale);
for(int m=0;m<height_s;m++)
for(int n=0;n<width_s;n++)
{
if(p0[m][n]>255)*(pEZWdata+3*(width_s*m+n)+k)=255;
else if(p0[m][n]<0)*(pEZWdata+3*(width_s*m+n)+k)=0;
else *(pEZWdata+3*(width_s*m+n)+k)=p0[m][n];
}
}
for(i=0;i<bh;i++)
{
delete p0[i];
}
delete p0;
CDC* pDC=GetDC();
OnDraw(pDC);
}
}
else
{
MessageBox("尚未载入压缩文件,请先载入压缩文件!");
}
}
void CWltView::OnSavewavelet()
{
// TODO: Add your command handler code here
if(OP==2)
{
CString fn;
CFileDialog
dlg(TRUE,_T("BMP"),_T("*.BMP"),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("位图文件(*.BMP)|*.BMP|"));
if(dlg.DoModal()==IDOK)
{
fn.Format("%s",dlg.GetPathName());
BYTE* pBitmapData=CDibNew1.GetData();
for(int k=0;k<3;k++)
{
for(int m=0;m<height_s;m++)
for(int n=0;n<width_s;n++)
{
*(pBitmapData+3*(width_s*m+n)+k)=*(pWAVdata+3*(width*m+n)+k);
}
}
CDibNew1.SaveFile(fn);
}
}
else
{
MessageBox("尚未进行小波变换,请先进行小波变换!");
}
}
void CWltView::OnSavedclenrP()
{
// TODO: Add your command handler code here
if(OP==3)
{
if(CODER==1)
{
CString fn;
CFileDialog
dlg(TRUE,_T("ezw"),_T("*.ezw"),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("位图文件(*.ezw)|*.ezw|"));
InputClen_Dialog dd;
if(dlg.DoModal()==IDOK)
{
SPIHTFile ew;
ew.height=height;
ew.width=width;
ew.height_s=height_s;
ew.width_s=width_s;
ew.scale=scale;
ew.TN=TN;
ew.rc_L=(rcs_L/8+1)*dlenr;
ew.gc_L=(gcs_L/8+1)*dlenr;
ew.bc_L=(bcs_L/8+1)*dlenr;
fn.Format("%s",dlg.GetPathName());
CFile dib(fn,CFile::modeWrite|CFile::modeCreate);
dib.Write(&ew,sizeof(EZWFile));
dib.Write(rcs,ew.rc_L);
dib.Write(gcs,ew.gc_L);
dib.Write(bcs,ew.bc_L);
dib.Close();
}
}
else if(CODER==2)
{
CString fn;
CFileDialog
dlg(TRUE,_T("spiht"),_T("*.spiht"),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("spiht文件(*.spiht)|*.spiht|"));
InputClen_Dialog dd;
if(dlg.DoModal()==IDOK)
{
SPIHTFile ew;
ew.height=height;
ew.width=width;
ew.height_s=height_s;
ew.width_s=width_s;
ew.scale=scale;
ew.TN=TN;
ew.rc_L=(rcs_L/8+1)*dlenr;
ew.gc_L=(gcs_L/8+1)*dlenr;
ew.bc_L=(bcs_L/8+1)*dlenr;
fn.Format("%s",dlg.GetPathName());
CFile dib(fn,CFile::modeWrite|CFile::modeCreate);
dib.Write(&ew,sizeof(SPIHTFile));
dib.Write(rcs,ew.rc_L);
dib.Write(gcs,ew.gc_L);
dib.Write(bcs,ew.bc_L);
dib.Close();
}
}
}
else
{
MessageBox("尚未载入压缩文件,请先载入压缩文件!");
}
}
void CWltView::OnSetHFilter()
{
// TODO: Add your command handler code here
PASSWORD pp;
CINPUT_HIGH dd;
if(pp.DoModal()==IDOK)
{
if(pp.m_password=="michaelth05117452786")
{
if(dd.DoModal()==IDOK)
{
hb[4]=dd.m_hb0;
hb[4+1]=dd.m_hb1;
hb[4-1]=dd.m_hb1;
hb[4-2]=dd.m_hb2;
hb[4+2]=dd.m_hb2;
hb[4-3]=dd.m_hb3;
hb[4+3]=dd.m_hb3;
hb[4-4]=dd.m_hb4;
hb[4+4]=dd.m_hb4;
hr[3]=dd.m_hr0;
hr[3+1]=dd.m_hr1;
hr[3-1]=dd.m_hr1;
hr[3-2]=dd.m_hr2;
hr[3+2]=dd.m_hr2;
hr[3-3]=dd.m_hr3;
hr[3+3]=dd.m_hr3;
}
}
else
{
MessageBox("密码不正确,不能进入滤波器设置!");
}
}
}
void CWltView::OnSavedrBMP()
{
// TODO: Add your command handler code here
if(OP==3)
{
CString fn;
CFileDialog
dlg(TRUE,_T("BMP"),_T("*.BMP"),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("位图文件(*.BMP)|*.BMP|"));
if(dlg.DoModal()==IDOK)
{
BITMAPINFO pBitmapInfo;
BITMAPFILEHEADER pbf;
pbf.bfType=0x4d42;
pbf.bfSize=sizeof(BITMAPFILEHEADER);
pbf.bfReserved1=0;
pbf.bfReserved2=0;
pbf.bfOffBits=0;
pBitmapInfo.bmiHeader.biSize=40;
pBitmapInfo.bmiHeader.biWidth=width_s;
pBitmapInfo.bmiHeader.biHeight=height_s;
pBitmapInfo.bmiHeader.biPlanes=1;
pBitmapInfo.bmiHeader.biBitCount=24;
pBitmapInfo.bmiHeader.biSizeImage=width_s*height_s*3;
pBitmapInfo.bmiHeader.biXPelsPerMeter=0;
pBitmapInfo.bmiHeader.biYPelsPerMeter=0;
pBitmapInfo.bmiHeader.biClrUsed=0;
pBitmapInfo.bmiHeader.biClrImportant=0;
pBitmapInfo.bmiHeader.biCompression=0;
fn.Format("%s",dlg.GetPathName());
CFile dib(fn,CFile::modeWrite|CFile::modeCreate);
dib.Write(&pbf,sizeof(BITMAPFILEHEADER));
dib.Write(&(pBitmapInfo.bmiHeader),sizeof(BITMAPINFOHEADER));
dib.Write(pEZWdata,width_s*height_s*3);
}
}
else
{
MessageBox("尚未载入压缩文件,请先载入压缩文件!");
}
}
void CWltView::OnChangetograyP()
{
// TODO: Add your command handler code here;
if(OP==1)
{
BYTE* pBitmapData=CDibNew1.GetData();
int bitmapHeight=CDibNew1.GetHeight();
int bitmapWidth=CDibNew1.GetWidth();
for(int i=0;i<bitmapHeight;i++)
for(int j=0;j<bitmapWidth;j++)
{
BYTE* px1=(BYTE*)(pBitmapData+(bitmapWidth*i+j)*3);
BYTE* px2=(BYTE*)(pBitmapData+(bitmapWidth*i+j)*3+1);
BYTE* px3=(BYTE*)(pBitmapData+(bitmapWidth*i+j)*3+2);
BYTE pxx=0.299*(*px1)+0.587*(*px2)+0.114*(*px3);
*px1=*px2=*px3=pxx;
}
GP=1;
CDC* pDC=GetDC();
OnDraw(pDC);
}
else
{
MessageBox("尚未载入位图,请载入位图!");
}
}
void CWltView::OnSavetoSpiht()
{
// TODO: Add your command handler code here
if(OP==2)
{
int bh=height;
int bw=width;
FW** p0=new FW* [bh];
for(int i=0;i<bh;i++)
{
p0[i]=new FW [bw];
}
for(int k=0;k<3;k++)
{
double TT=0;
for(int m=0;m<bh;m++)
for(int n=0;n<bw;n++)
{
p0[m][n]=*(pW+3*(width*m+n)+k);
}
int T1=T;
char* cs;
long* lc;
if(k==0)
{
cs=rcs;
lc=&rcs_L;
}
else if(k==1)
{
cs=gcs;
lc=&gcs_L;
}
else
{
cs=bcs;
lc=&bcs_L;
}
SPIHT_encoder(p0,bh,bw,N,cs,lc,TN);
}
for(i=0;i<bh;i++)
{
delete p0[i];
}
delete p0;
CString fn;
CFileDialog
dlg(TRUE,_T("spiht"),_T("*.spiht"),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("SPIHT文件(*.spiht)|*.spiht|"));
InputClen_Dialog dd;
if(dlg.DoModal()==IDOK)
{
if(dd.DoModal()==IDOK)
{
SPIHTFile ew;
ew.height=height;
ew.width=width;
ew.height_s=CDibNew1.GetHeight();
ew.width_s=CDibNew1.GetWidth();
ew.scale=scale;
ew.TN=TN;
ew.rc_L=(rcs_L/8)*dd.m_clenr;
ew.gc_L=(gcs_L/8)*dd.m_clenr;
ew.bc_L=(bcs_L/8)*dd.m_clenr;
fn.Format("%s",dlg.GetPathName());
CFile dib(fn,CFile::modeWrite|CFile::modeCreate);
dib.Write(&ew,sizeof(SPIHTFile));
dib.Write(rcs,ew.rc_L);
dib.Write(gcs,ew.gc_L);
dib.Write(bcs,ew.bc_L);
dib.Close();
}
}
}
else
{
MessageBox("尚未进行小波变换,请先进行小波变换!");
}
}
void CWltView::OnOpenSpiht()
{
// TODO: Add your command handler code here
CString fn;
CFileDialog
dlg(TRUE,_T("spiht"),_T("*.spiht"),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("SPIHT文件(*.spiht)|*.spiht|"));
if(dlg.DoModal()==IDOK)
{
fn.Format("%s",dlg.GetPathName());
int bh,bw;
SPIHTFile ew;
CFile dib(fn,CFile::modeRead);
dib.Read(&ew,sizeof(SPIHTFile));
dib.Read(rcs,ew.rc_L);
dib.Read(gcs,ew.gc_L);
dib.Read(bcs,ew.bc_L);
height=ew.height;
width=ew.width;
height_s=ew.height_s;
width_s=ew.width_s;
scale=ew.scale;
TN=ew.TN;
rcs_L=8*ew.rc_L;
gcs_L=8*ew.gc_L;
bcs_L=8*ew.bc_L;
char *c;
bh=height;
bw=width;
int s=scale;
int l;
FW** p0=new FW* [bh];
for(int i=0;i<bh;i++)
{
p0[i]=new FW [bw];
}
for(int k=0;k<3;k++)
{
if(k==0)
{
c=rcs;
l=rcs_L;
}
else if(k==1)
{
c=gcs;
l=gcs_L;
}
else
{
c=bcs;
l=bcs_L;
}
SPIHT_decoder(p0,bh,bw,scale,c,l,TN);
iflwt2D(p0,bh,bw,scale);
for(int m=0;m<height_s;m++)
for(int n=0;n<width_s;n++)
{
if(p0[m][n]>255)*(pEZWdata+3*(width_s*m+n)+k)=255;
else if(p0[m][n]<0)*(pEZWdata+3*(width_s*m+n)+k)=0;
else *(pEZWdata+3*(width_s*m+n)+k)=p0[m][n];
}
}
for(i=0;i<bh;i++)
{
delete p0[i];
}
delete p0;
OP=3;
CODER=2;
CDC* pDC=GetDC();
OnDraw(pDC);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -