【正文】
DC hDC。t work if (!GetObject(hBitmap, sizeof(bm), (LPBYTE)amp。 // make sure bits per pixel is valid if (biBits = 1) biBits = 1。 // initialize BITMAPINFOHEADER = sizeof(BITMAPINFOHEADER)。 = biBits。 = 0。bi)。 // alloc memory block to store our bitmap hDIB = GlobalAlloc(GHND, dwLen)。 ReleaseDC(NULL, hDC)。 // 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)。 // realloc the buffer big enough to hold all the bits dwLen = + PaletteSize((LPBYTE)amp。 hDIB = NULL。 return NULL。 SelectPalette(hDC, hPal, TRUE)。 } bi = *lpbi。 ReleaseDC(NULL, hDC)。 // Pointer to DIB info structure HANDLE fh。 fh = CreateFile(lpFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL)。 return FALSE。t written to deal with these // DIBs. if (lpBIbiSize != sizeof(BITMAPINFOHEADER)) { 理學(xué)學(xué)士學(xué)位論文 第二章 分形 相關(guān) 理 論 問題 21 GlobalUnlock(hDib)。 // BM dwDIBSize = *(LPDWORD)lpBI + PaletteSize((LPBYTE)lpBI)。 else { DWORD dwBmBitsSize。 // Now, since we have calculated the correct size, why don39。 = 0。bmfHdr,sizeof(BITMAPFILEHEADER), amp。 GlobalUnlock(hDib)。 // Success code } 理學(xué)學(xué)士學(xué)位論文 第三章 畢業(yè)設(shè)計(jì)結(jié)果與分析 23 第三章 畢業(yè)設(shè)計(jì)結(jié)果和分析 給出畢業(yè)設(shè)計(jì)的結(jié)果圖,并給出適當(dāng)?shù)姆治觯赋銎鋬?yōu)勢(shì)和不足之處。 ○ 3 退出 : 退出當(dāng)前程序。 理學(xué)學(xué)士學(xué)位論文 第三章 畢業(yè)設(shè)計(jì)結(jié)果與分析 24 。 子菜單: ○ 1 Julia 集:查看 Julia 集圖。 子菜單: ○ 1 新建:新建一個(gè)視圖。 if (dwWritten == 0) return FALSE。 // Write the DIB header and the bits use local version of // MyWrite, so we can write more than 32767 bytes of data WriteFile(fh, (LPBYTE)lpBI, dwDIBSize, amp。s the Bitmap file header plus the DIB header, // plus the size of the color table. = (DWORD)sizeof(BITMAPFILEHEADER) + lpBIbiSize +PaletteSize((LPBYTE)lpBI)。 } // Calculate the file size by adding the DIB size to sizeof(BITMAPFILEHEADER) = dwDIBSize + sizeof(BITMAPFILEHEADER)。s not RLE, so size is Width (DWORD aligned) * Height dwBmBitsSize = WIDTHBYTES((lpBIbiWidth)*((DWORD)lpBIbiBitCount)) * lpBIbiHeight。s an RLE bitmap, we can39。 return FALSE。re dealing with an OS/2 DIB. If so, don39。 // Get a pointer to the DIB memory, the first of which contains // a BITMAPINFO structure lpBI = (LPBITMAPINFOHEADER)GlobalLock(hDib)。 DWORD dwWritten。 } bool CGlobal::SaveDIB(HANDLE hDib, LPCTSTR lpFileName) { BITMAPFILEHEADER bmfHdr。 SelectPalette(hDC, hPal, TRUE)。 ReleaseDC(NULL, hDC)。 // call GetDIBits with a NONNULL lpBits param, and actualy get the // bits this time if (GetDIBits(hDC, hBitmap, 0, (UINT), (LPBYTE)lpbi + (WORD)lpbibiSize + PaletteSize((LPBYTE)lpbi), (LPBITMAPINFO)lpbi, DIB_RGB_COLORS) == 0) { // clean up and return NULL GlobalUnlock(hDIB)。 RealizePalette(hDC)。 if (h = GlobalReAlloc(hDIB, dwLen, 0)) hDIB = h。 GlobalUnlock(hDIB)。 } // lock memory and get pointer to it lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB)。t get memory block if (!hDIB) { // clean up and return NULL SelectPalette(hDC, hPal, TRUE)。 // select and realize our palette hPal = SelectPalette(hDC, hPal, FALSE)。 = 0。 = 0。 = 。 else if (biBits = 8) biBits = 8。 // if no palette is specified, use default palette if (hPal == NULL) hPal = (HPALETTE)GetStockObject(DEFAULT_PALETTE)。 // bits per pixel // check if bitmap handle is valid if (!hBitmap) return NULL。 // pointer to BITMAPINFOHEADER DWORD dwLen。 // return handle to the bitmap return hBitmap。 // bitblt screen DC to memory DC 理學(xué)學(xué)士學(xué)位論文 第二章 分形 相關(guān) 理 論 問題 16 BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY)。 nWidth = nX2 nX。 //make sure bitmap rectangle is visible if (nX 0) nX = 0。 nX2 = lpRectright。 // create a DC for the screen and create // a memory DC patible to screen DC hScrDC = CreateDC(DISPLAY, NULL, NULL, NULL)。 // coordinates of rectangle to grab int nWidth, nHeight。 // return handle to the packedDIB return hDIB。 // get the current palette hPalette = GetSystemPalette()。 // handle to devicedependent bitmap HPALETTE hPalette。 lpRectbottom = 。pt2)。 = lpRectbottom。 POINT pt1, pt2。 HANDLE hDib = (GetSafeHwnd(), NowRect)。 附相關(guān)代碼如下: 圖片保存函數(shù): void CFractalView::OnFileSave() { CFileDialog dlg(TRUE, NULL, *.bmp,OFN_HIDEREADONLY ,Bmp Files(*.bmp)|*.bmp)。 2, 位圖的復(fù)制和剪切。得到需 要的客戶區(qū)域 lpRect 后,將 lpRect 指向的區(qū)域拷貝成 Bitmap,使用 BitBlt(HDC,int,int,int,int,HDC,int,int,unsigned long)。然后需要確定當(dāng)前客戶區(qū)域的大小,而這個(gè)可以使用函數(shù) void GetClientRect( LPRECT lpRect ) const。然后使用類成員函數(shù) GetFileName()就可以獲得用戶輸入的文件名。 如果 i 1000? , 結(jié)束循環(huán)。w = a * x + 2 * ( 1 a ) * x * x / ( 1 + u ) 。 最后一個(gè)重要的影響因素是初始值 , 典型的初始值 X 和 Y 在 20和 20 之間 。 圖形參見:圖 。 且 每 個(gè) 格 子 的 初 始 狀 態(tài) 均 為 0 ,即 F(x,y)=0 ,設(shè)0 0 0 0/ 2 , / 2 , ( , ) 1x a y a F x y? ? ?,將此網(wǎng)格的中心部分 00( , )xy 點(diǎn)為中心,將 00( , )xy以 外的點(diǎn)分成若干層次,緊靠 00( , )xy 的 8 個(gè)點(diǎn)為第一層,緊靠第一層外面的 16點(diǎn) 為第二層,緊靠第二層外面的 24 個(gè)點(diǎn)為第三層,以此類推,一直到最外面一層。 ○ D 返回值 00x,y ,回到算法步驟 ○ 3 繼續(xù)進(jìn)行運(yùn)算。又因?yàn)樘右輹r(shí)間算