资源预览内容
第1页 / 共13页
第2页 / 共13页
第3页 / 共13页
第4页 / 共13页
第5页 / 共13页
第6页 / 共13页
第7页 / 共13页
第8页 / 共13页
第9页 / 共13页
第10页 / 共13页
亲,该文档总共13页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
用 VC6.0 建一个对话框窗体,命名为 Chaos在 ChaosDlg.cpp 文件下:BOOL CChaosDlg:OnInitDialog()CDialog:OnInitDialog();MoveWindow(0,0,1024,768,true);/ Add About. menu item to system menu./ IDM_ABOUTBOX must be in the system command range.ASSERT(IDM_ABOUTBOX ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);/ Set the icon for this dialog. The framework does this automatically/ when the applications main window is not a dialogSetIcon(m_hIcon, TRUE); / Set big iconSetIcon(m_hIcon, FALSE); / Set small icon/角度的分界线tan_1=tan(60*pi/180.0);tan_2=tan(120*pi/180.0);tan_3=tan(240*pi/180.0);tan_4=tan(300*pi/180.0);return TRUE; / return TRUE unless you set the focus to a controlvoid CChaosDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;2dlgAbout.DoModal();elseCDialog:OnSysCommand(nID, lParam);/ If you add a minimize button to your dialog, you will need the code below/ to draw the icon. For MFC applications using the document/view model,/ this is automatically done for you by the framework.void CChaosDlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();/*将作图区域底色设为白色*/CRect rec;rec.left=0;rec.top=0;rec.right=767;rec.bottom=767;CDC *dc;3dc=this-GetDC();CBrush hbr;hbr.CreateSolidBrush(RGB(255,255,255);dc-FillRect(/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CChaosDlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CChaosDlg:OnOK() / TODO: Add extra validation hereUpdateData(TRUE);CDC *dc;dc=this-GetDC();double x0,y0,x1,y1,dx,dy;int col,row,color;/绘图范围是-2,2/dx=dy=4.0/767.0;for(col=0;colSetPixel(col,767-row,colorlistcolor);dc-MoveTo(20-1,20-1);dc-LineTo(747+1,20-1);dc-LineTo(747+1,747+1);dc-LineTo(20-1,747+1);dc-LineTo(20-1,20-1);/4/画出图形 /for(col=20;colm_edit1);y1=itearate_fim(x0,y0,this-m_edit1);color=judge_color_point(x1,y1);dc-SetPixel(col,767-row,colorlistcolor);x0=x1;y0=y1;UpdateData(FALSE);int CChaosDlg:judge_color_point(double x, double y)int z1;double division;if(x0&y0)division=y/x;if(division=0)division=y/x;if(division0&y0)z1=2;if(x=0&y=0;i-)for(j = 767;j =0;j-)clr = dc.GetPixel(i, j);r = GetRValue(clr);g = GetGValue(clr);b = GetBValue(clr);if(r != 255 | g != 255 | b != 255)flag = 1;x2 = i;break;if(flag)break;flag = 0;for(j = 0;j =0;j-)for(i = x2;i =x1;i-)clr = dc.GetPixel(i, j);r = GetRValue(clr);g = GetGValue(clr);b = GetBValue(clr);if(r != 255 | g != 255 | b != 255)flag = 1;y2 = j;break;if(flag)break;/保存图片CRect rect;rect.SetRect(x1,y1,x2,y2);/ CClientDC dc(this); CDC memDC;/ CRect rect;memDC.CreateCompatibleDC(9CBitmap bm;int Width = 768;int Height = 768;bm.CreateCompatibleBitmap(CBitmap* pOld = memDC.SelectObject(memDC.BitBlt(0, 0, Width, Height, memDC.SelectObject(pOld);BITMAP btm;bm.GetBitmap(DWORD size = btm.bmWidthBytes * btm.bmHeight;LPSTR lpData = (LPSTR)GlobalAllocPtr(GPTR, size);BITMAPFILEHEADER bfh;/BITMAPINFOHEADER bih;bih.biBitCount = btm.bmBitsPixel;bih.biClrImportant = 0;bih.biClrUsed = 0;bih.biCompression = 0;bih.biHeight = btm.bmHeight;bih.biPlanes = 1;bih.biSize = sizeof(BITMAPINFOHEADER);bih.biSizeImage = size;bih.biWidth = btm.bmWidth;bih.biXPelsPerMeter = 0;bih.biYPelsPerMeter = 0;GetDIBits(dc,bm,0,bih.biHeight,lpData,(BITMAPINFO*)/bm.GetBitmapBits(size,lpData);/此函数在处理 5-5-5 模式的 16 位色下会出现颜色混乱bfh.bfReserved1 = bfh.bfReserved2 = 0;bfh.bfType = (WORD)(MGetDC();CBrush hbr;hbr.CreateSolidBrush(RGB(255,255,255);dc-FillRect(/double x0=-0.5,y0=0.5,x1,y1,dx,dy;dx=dy=4.0/767.0;int col0,row0,col1,row1;col0=(int)(x0+2)/dx);row0=767-(int)(y0+2)/dy);for(int i=0;iSetPixel(col0,767-row0,RGB(255,0,0);x0=x1;y0=y1;/x 轴/col0=(int)(-2+2)/dx);11row0=767-(int)(0+2)/dy);col1=(int)(2+2)/dx);row1=767-(int)(0+2)/dy);dc-MoveTo(col0,row0);dc-LineTo(col1,row1);/y 轴/col0=(int)(0+2)/dx);row0=767-(int)(-2+2)/dy);col1=(int)(0+2)/dx);row1=767-(int)(2+2)/dy);dc-MoveTo(col0,row0);dc-LineTo(col1,row1);Col.h 文件下:double tan_1,tan_2,tan_3,tan_4;COLORREF colorlist6=RGB(210,189,93),RGB(169,144,30),RGB(56,50,22),RGB(127,123,15),RGB(199,194,49),RGB(237,228,133)1213所做图形:迭代 0 次 迭代 1 次迭代 2 次 迭代 3 次迭代 4 次
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号