【正文】
集圖形:見圖 。 2211 2t t tt t tx x y py x y q??????? ○ 4 計算 22ttr x y??: 如果 rM? ,則轉(zhuǎn)到步驟 ○ 5 。 ○ 2 令 m a x m i n( ) /( 1 )x x x w id th? ? ? ? m a x m in( ) /( 1 )y y y h e igh t? ? ? ? ○ 3 利用下式從 ( , )kkxy 得到 11( , )kkxy??,計數(shù) k=k+1 2211 2k k kk k kx x y py x y q??????? ○ 4 計算 22ttr x y??: 如果 rM? ,則轉(zhuǎn)到步驟 ○ 5 。 在數(shù)字視頻中,對 RGB 三基色各進(jìn)行 8 位編碼就構(gòu)成了大約 萬種顏色,這就是我們常說的真彩色。如果 R,G,B 中的任何一個值大于0xFF,就對其進(jìn)行 ^0xFF 的位運(yùn)算。 上面的 red, green, blue 分別表示 RGB 顏色模型中的 R, G, B。如果要對窗口中的圖形進(jìn)行移動,我們可以選擇使用移動參數(shù)窗口的方法來實現(xiàn)。?? 經(jīng)過實驗證明,這個方法對 Julia 集與 Mandelbrot 集都適用。???? 這樣我們只要將得到的 (xMin,yMin), (xMax,yMax)代替原來的參數(shù)窗口值就可以實現(xiàn)對窗口的放大 了。m in m in m in39。 2211 2t t tt t tx x y py x y q??????? 這里只需要修改 ,xynn的值,所以可得: xx x yyte m p = nn = w idth /2 + ( n w idth /2) * c o s ( n h e igh t/ 2 ) * sinn = h e igh t/ 2 + ( te m p w idth /2) * sin + ( n y h e igh t/ 2 ) * c o s???? 再將獲得的 ,xynn,進(jìn)行 m in *txx x n x? ? ?, m in *tyy y n y? ? ?的運(yùn)算,得到新的,ttxy。 ○ D 返回值 00x,y ,回到算法步驟 ○ 3 繼續(xù)進(jìn)行運(yùn)算。 圖形參見:圖 。w = a * x + 2 * ( 1 a ) * x * x / ( 1 + u ) 。然后使用類成員函數(shù) GetFileName()就可以獲得用戶輸入的文件名。得到需 要的客戶區(qū)域 lpRect 后,將 lpRect 指向的區(qū)域拷貝成 Bitmap,使用 BitBlt(HDC,int,int,int,int,HDC,int,int,unsigned long)。 附相關(guān)代碼如下: 圖片保存函數(shù): void CFractalView::OnFileSave() { CFileDialog dlg(TRUE, NULL, *.bmp,OFN_HIDEREADONLY ,Bmp Files(*.bmp)|*.bmp)。 POINT pt1, pt2。pt2)。 // handle to devicedependent bitmap HPALETTE hPalette。 // return handle to the packedDIB return hDIB。 // create a DC for the screen and create // a memory DC patible to screen DC hScrDC = CreateDC(DISPLAY, NULL, NULL, NULL)。 //make sure bitmap rectangle is visible if (nX 0) nX = 0。 // bitblt screen DC to memory DC 理學(xué)學(xué)士學(xué)位論文 第二章 分形 相關(guān) 理 論 問題 16 BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY)。 // pointer to BITMAPINFOHEADER DWORD dwLen。 // if no palette is specified, use default palette if (hPal == NULL) hPal = (HPALETTE)GetStockObject(DEFAULT_PALETTE)。 = 。 = 0。t get memory block if (!hDIB) { // clean up and return NULL SelectPalette(hDC, hPal, TRUE)。 GlobalUnlock(hDIB)。 RealizePalette(hDC)。 ReleaseDC(NULL, hDC)。 } bool CGlobal::SaveDIB(HANDLE hDib, LPCTSTR lpFileName) { BITMAPFILEHEADER bmfHdr。 // Get a pointer to the DIB memory, the first of which contains // a BITMAPINFO structure lpBI = (LPBITMAPINFOHEADER)GlobalLock(hDib)。 return FALSE。s not RLE, so size is Width (DWORD aligned) * Height dwBmBitsSize = WIDTHBYTES((lpBIbiWidth)*((DWORD)lpBIbiBitCount)) * lpBIbiHeight。s the Bitmap file header plus the DIB header, // plus the size of the color table. = (DWORD)sizeof(BITMAPFILEHEADER) + lpBIbiSize +PaletteSize((LPBYTE)lpBI)。 if (dwWritten == 0) return FALSE。 子菜單: ○ 1 Julia 集:查看 Julia 集圖。 ○ 3 退出 : 退出當(dāng)前程序。 GlobalUnlock(hDib)。 = 0。 else { DWORD dwBmBitsSize。t written to deal with these // DIBs. if (lpBIbiSize != sizeof(BITMAPINFOHEADER)) { 理學(xué)學(xué)士學(xué)位論文 第二章 分形 相關(guān) 理 論 問題 21 GlobalUnlock(hDib)。 fh = CreateFile(lpFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL)。 ReleaseDC(NULL, hDC)。 SelectPalette(hDC, hPal, TRUE)。 hDIB = NULL。 // call GetDIBits with a NULL lpBits param, so it will calculate the // biSizeImage field for us GetDIBits(hDC, hBitmap, 0, (UINT), NULL, (LPBITMAPINFO)lpbi, DIB_RGB_COLORS)。 // alloc memory block to store our bitmap hDIB = GlobalAlloc(GHND, dwLen)。 = 0。 // initialize BITMAPINFOHEADER = sizeof(BITMAPINFOHEADER)。t work if (!GetObject(hBitmap, sizeof(bm), (LPBYTE)amp。 // bitmap structure BITMAPINFOHEADER bi。 // create a bitmap patible with the screen DC hBitmap = CreateCompatibleBitmap(hScrDC, nWidth, nHeight)。 // get screen resolution xScrn = GetDeviceCaps(hScrDC, HORZRES)。 // screen resolution // check for an empty rectangle 理學(xué)學(xué)士學(xué)位論文 第二章 分形 相關(guān) 理 論 問題 15 //MessageBox((HWND)AfxGetApp()GetMainWnd(),122,123,NULL)。 // clean up DeleteObject(hPalette)。 // return the handle to the DIB return hDIB。pt1)。 } } 拷貝客戶區(qū)函數(shù): HDIB CGlobal::CopyClientRectToDIB(HWND hWnd, LPRECT lpRect) { HDIB hDIB = NULL。復(fù)制圖形區(qū)域為位圖上面我們已經(jīng)介紹過了,這 里不再贅述,而重畫選定區(qū)域也只需要一個 Rectangle()函數(shù)就可以實現(xiàn)。為了拷貝客戶區(qū)的圖形到內(nèi)存,我寫了一個函數(shù) CopyClientRectToDIB(HWND hander,CRect rect),其中的 hander為當(dāng)前窗口的句柄, rect 表示客戶區(qū)域的大小。 分形圖形的位圖操作 1, 圖形的保存:圖形的保存可以分為三個步驟,先獲取用戶想要將圖形保存為的文件名,然后再將當(dāng)前客戶區(qū)的圖形拷貝成位圖,最后將位圖寫入文件。 ○ 2 進(jìn)行 計算: z = x 。 ○ 2 對 ( , ) 1iiF x y ? 的點著色。 ○ B 理學(xué)學(xué)士學(xué)位論文 第二章 分形 相關(guān) 理 論 問題 10 00t 3 = t 1 * t 1 t 2 * t 2 + x 0 .7t 4 = 2 * t 1 * t 2 + yt 1 = t 3t 2 = t 4 計數(shù) i=i+1。 r r rx = x + ( x x ) * c o s ( y y ) * s iny = y + ( x x ) * s in + ( y y ) * c o s?? 將這個式子應(yīng)用到 Julia 集繪制算法中,這里假定繞屏幕的中點旋轉(zhuǎn),屏幕的寬度為 width,高度為 height,用坐標(biāo)表示為 (width/2, height/2),從前面繪制 Julia 集的方法中可知下列兩個步驟: ○ 1 0 min *xx x n x? ? ?, 0 m in *yy y n y? ? ?。將其寫成矩陣形式如下: 39。y Min = y Min + y * ol dP oint .y 。y Mi n = y Mi n y * ( ne wP oi nt .y ol dP oi nt .y ) 。 Julia 集與 Mandelbrot 集圖形的矢量變換 1, Julia 集與 Mandelbrot 集的矢量移動:在逃逸時間算法中,一共有兩個窗口,一個是繪圖窗口,一個是參數(shù)窗口,其中繪圖窗口的大小與位置相對來說是固定的,因為它對應(yīng)的是窗口的分辨率。 if ((blue amp。 下面對求得的 red, gr