VC_设置窗口大小及图像的显示(VC_ setting window size and image display)
VC_设置窗口大小及图像的显示(VC_ setting window size and image
display)
VC settings window size!
/ / SetWindowPos (NULL, 0,0200300, SWP_NOMOVE);
/ / dismissed (0,0), only the size changed to 200x300, the same position
/ / SetWindowPos (NULL, 0,0200300, SWP_NOMOVE);
/ / said they did not consider 200X300, just moved to the position of the same size (0,0).
/ / if you want to change at the same time the last available SWP_NOZORDER
There are SWP_SHOWWINDOW / / parameters display window corresponding to the SWP_HIDEWINDOW
/ / create from file CImagine
/ / open image file
Void, OnFileOpen ()
{
CString strFilter;
CSimpleArray
aguidFileTypes;
HRESULT hResult;
Get / / filter string image file supported by Cimage
HResult = m_image.GetExporterFilterString (strFilter, aguidFileTypes, _T (All, Image, Types));
If (FAILED (hResult))
{
MessageBox (calling GetExporterFilter failed! ");
Return;
}
CFileDialog, DLG (TRUE, NULL, NULL, OFN_FILEMUSTEXIST, strFilter);
If (IDOK = = dlg.DoModal ())
{
Return;
}
M_image.Destroy ();
/ / external image file loading Cimage object
HResult = m_image.Load (dlg.GetFileName ());
If (FAILED (hResult))
{
"MessageBox" failed to call the image file! ");
Return;
}
/ / set the main window title bar content
CString str;
Str.LoadString (AFX_IDS_APP_TITLE);
(AfxGetMainWnd) ->SetWindowText (STR + dlg.GetFileName) + "_"
();
Invalidate (OnDraw); / / mandatory call
}
/ / save picture file
Void, OnFileSaveAs ()
{
If (m_image.IsNull ())
{
MessageBox ("you have not opened the graphic file you want to save."! ");
Return;
}
The following procedures for selecting / / save the picture path and other information
CString strFilter=, bitmap file (*.bmp), |*.bmp|JPEG image file, |*.jpg|GIF image file, |*.gif|PNG image file, |*.png||";
CFileDialog, DLG (FALSE, BMP, untitled.bmp, NULL, strFilter);
If (IDOK = = dlg.DoModal ())
Return;
/ / if the user does not specify a file name extension, is to add a
CString strFileName;
CString strExtension;
StrFileName = dlg.m_ofn.lpstrFile;
If (dlg.m_ofn.nFileExtension = 0)
{
Switch (dlg.m_ofn.nFilterIndex)
{
Case 1:
StrExtension = "BMP"; break;
Case 2:
StrExtension = "JPG"; break;
Case 3:
StrExtension = "GIF"; break;
Case 4:
StrExtension = "PNG"; break;
Default:
Break;
}
StrFileName = strFileName + strExtension + '.';
}
/ / save the image
HRESULT hResult = m_image.Save (strFileName);
If (FAILED (hResult))
MessageBox (save image file failed)! ");
Else
MessageBox (save the image file successfully! ");
}
/ / set to black and white pictures.
Void MakeBlackAndWhite (CImage* image)
{
If (image->IsNull ())
{
Return;
}
If (image->IsIndexed) (!) / / whether to use the color table
to judge
{
/ / directly modify the pixel color
COLORREF pixel;
Int maxY = image->GetHeight ();
Int maxX = image->GetWidth ();
Byte, R, G, B, avg;
为(int x = 0;x,Maxx;X + +)
{
为(y = 0;Y,糯;Y + +)
{
像素=图像-> GetPixel(x,y);
R = getrvalue(像素);
G = getgvalue(像素);
B = getbvalue(像素);
AVG =(int)((r + G + B)/ 3);
图像-> setpixelrgb(x,y,AVG AVG,AVG);
}
}
}
其他的
{
/ /获取并修改颜色
表
关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf
国际maxcolors =图像-> getmaxcolortableentries();
颜色表项*颜色;
颜色=新的颜色表项[ maxcolors ];
图像-> getcolortable(0,maxcolors,颜色);
为(int i = 0;i < maxcolors;i++)
{
国际平均值=(颜色[我]。rgbblue +颜色[我]。rgbgreen +颜色[我]。图像)/ 3;
颜色[我]。rgbblue = AVG;
颜色[我]。rgbgreen = AVG;
颜色[我]图像=平均;
}
图像-> setcolortable(0,maxcolors,颜色);
删除(颜色);
}
}
/ / GDI+显示图像并旋转
无效imagerotate()
,
图形图形(* PDC);
图像(/ * L C:\井位图1。JPG”* / L”。\物\构造图.jpg”);
矩形(700,0,形象。getwidth(),形象。getheight());
图形。绘制图像(图像、矩形);
点[ ] = {点(0,0),点(图像。getwidth(),0),点(0,图像。getheight())};
矩阵(1,0,0,1,10,10);/ /定义一个单位矩阵,坐标原点在(10,10)
矩阵。旋转(30);//顺时针旋转30度
矩阵表(0.5,0.5);/ /缩小比例
矩阵。transformpoints(分,3);//用矩阵转换点
图形。绘制图像(图像、点,3);
,