⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oxdib.h

📁 《Windows多媒体编程基础》书第五章源代码SimpleBrowse一款简单易用的图片浏览器。其他目录中都是编译时需要的库和包含文件等(Bin是调试输出)。该工程较好的演示了一个工程中个要素之间的关
💻 H
📖 第 1 页 / 共 2 页
字号:
	//				To be of any use, the global memory must be locked
	
	CSize GetSize(LPSTR lpDIBHeader = NULL) const;
	// --- In  :
	// --- Out : 
	// --- Returns : The size of the IDB
	// --- Effect : This function gets the width of the DIB from the BITMAPINFOHEADER
	//				width field if it is a Windows 3.0-style DIB or from the BITMAPCOREHEADER
	//				width field if it is an other-style DIB.
 
	
	WORD GetPaletteSize(LPSTR lpDIBHeader = NULL) const;
	// --- In  :
	// --- Out : 
	// --- Returns : The size of the color palette of the DIB
	// --- Effect : This function gets the size required to store the DIB's palette by
	//				multiplying the number of colors by the size of an RGBQUAD (for a
	//				Windows 3.0-style DIB) or by the size of an RGBTRIPLE (for an other-
	//				style DIB).

	CPalette* GetPalette() const;	
	// --- In  :
	// --- Out : 
	// --- Returns : The palette of the DIB
	// --- Effect : It is possible that the DIB does not have a palette,
	//				a NULL pointer will be returned in this case
	
	WORD GetNumColors(LPSTR lpDIBHeader = NULL) const;
	// --- In  :
	// --- Out : 
	// --- Returns : The number of colors in the color table
	// --- Effect : This function calculates the number of colors in the DIB's color table
	//				by finding the bits per pixel for the DIB (whether Win3.0 or other-style
	//				DIB). If bits per pixel is 1: colors=2, if 4: colors=16, if 8: colors=256,
	//				if 24, no colors in color table.

	WORD GetNumBitsPerPixel(LPSTR lpDIBHeader = NULL) const;
	// --- In  :
	// --- Out : 
	// --- Returns : The number of bits used to represent one pixel
	// --- Effect : 
 

    void SetMonoColors(DWORD dwForeground, DWORD dwBackground, LPSTR lpDIBHeader = NULL);  
	// --- In  : dwForeground : 
	//			 dwBackground
	// --- Out : 
	// --- Returns : 
	// --- Effect :

    BOOL GetMonoColors(DWORD& dwForeground, DWORD& dwBackground, LPSTR lpDIBHeader = NULL); 
    // --- In  : dwForeground : 
	//			 dwBackground
	// --- Out : 
	// --- Returns : whether the palette was monochrome or not
	// --- Effect :
    
    COXDIB(const COXDIB& DIBSrc);
	// --- In :	DIBSrc : DIB object which will be copied
	// --- Out : 
	// --- Returns :
	// --- Effect : Copy contruction.
	//				Notice that global memory will be copied
    
	const COXDIB& operator=(const COXDIB& DIBSrc);
	// --- In :	DIBSrc : DIB object which will be assign to 'this' DIB object
	// --- Out:
	// --- Returns: 
	// --- Effect : Assignment operator

	const COXDIB& operator=(HDIB hDIBSrc);
	// --- In :	hDIBSrc : handle to DIB  which will be assign to 'this' DIB object
	// --- Out:
	// --- Returns: 
	// --- Effect : Assignment operator
	
	CBitmap* MakeBitmapFromDIB(CDC* pDC);
	// --- In  :  pDC : The device context with which characteristics the bitmap 
	//					will be made
	// --- Out : 
	// --- Returns : Pointer to the new bitmapc.
	// --- Effect : Creates out of the DIB a bitmap
	//				The bitmap is not selected into the dc
	
	HDIB BitmapToDIB (HBITMAP hBitmap, CPalette* pPal = NULL);
	// --- In :	hBitmap : HANDLE to global memory containing a BMP spec
	//                     (either BITMAPINFOHEADER or BITMAPCOREHEADER)
	//						compatible with default screen display device.
	//			pPal : Palette to render the DIB with.  If it's NULL,
	//                     use the default palette.		
	// --- Out:
	// --- Returns: a DIB made of the bmp
	// --- Effect : Given a handle to global memory with a DIB spec in it,
	//             and a palette, returns a device dependent bitmap.  The
	//             The DDB will be rendered with the specified palette.
	
	BOOL CreateEmptyDIB(WORD wBitsPerPix, DWORD dwWidth, DWORD dwHeight);
	// --- In :	wBitsPerPix : number of bits per pixel
	//			dwWidth : width of the new empty dib
	//			dwHeight : height of the new empty dib
	// --- Out:
	// --- Returns: succeeded or not
	// --- Effect : Creates a empty dib in this object with given size and bits per pixel
	//				Any previous dib contained in this object, is discarded.
	
	BOOL SetPaletteUsage(CPalette* pPal, UINT wUsage);
	// --- In :	pPal : the palette to adjust the DIB to
	//			wUsage : DIB_PAL_COLORS the DIB color table is set to 0-256
	//					 DIB_RGB_COLORS the DIB color table is set to the RGB values
	// --- Out:
	// --- Returns: succeeded or not
	// --- Effect : Modifies the color table of the DIB for use with the wUsage
	//				parameter specifed.

	BOOL ResizeDIB(DWORD dwWidth, DWORD dwHeight);
	// --- In :	dwWidth : the new width for the DIB
	//			dwHeight : the new height for the DIB
	// --- Out:
	// --- Returns: succeeded or not
	// --- Effect : Replaces this DIB with its Resized counterpart
	//				Any previous dib contained in this object, is discarded.
	//				ONLY supported for 24 bit and 8 bit DIB's

#ifndef NO_DITHER
	static BOOL GetHalfTonePalette(CPalette* pPalette);
	// --- In  :
	// --- Out : pPalette : the halftone palette
	// --- Returns : succeeded or not
	// --- Effect : Creates the halftone Palette

	BOOL HalfToneDitherDIB();
	// --- In :	
	// --- Out:
	// --- Returns: succeeded or not
	// --- Effect : Replaces this DIB with its halftone counterpart
	//				Any previous dib contained in this object, is discarded.
	//				You can use this to change 24-bit-pixel DIBS into 8-bit-pixel
	//				DIBS and display them on a 256 color display.
	//				ONLY supported for 24 bit DIB's
#endif // NO_DITHER
	
	void InitBitmapInfoHeader (PDIB lpBmInfoHdr, DWORD dwWidth,
                                        DWORD dwHeight,
                                          WORD nBPP);
	// --- In :	lpBmInfoHdr == Far pointer to a BITMAPINFOHEADER structure
	//                            to be filled in.
	//             dwWidth     == Width of DIB (not in Win 3.0 & 3.1, high
	//                            word MUST be 0).
	//             dwHeight    == Height of DIB (not in Win 3.0 & 3.1, high
	//                            word MUST be 0).
	//             nBPP        == Bits per Pixel for the DIB.		
	// --- Out:
	// --- Returns: 
	// --- Effect : Does a "standard" initialization of a BITMAPINFOHEADER,
	//             given the Width, Height, and Bits per Pixel for the
	//             DIB.
	//
	//             By standard, I mean that all the relevant fields are set
	//             to the specified values.  biSizeImage is computed, the
	//             biCompression field is set to "no compression," and all
	//             other fields are 0.
	//
	//             Note that DIBs only allow BitsPixel values of 1, 4, 8, or
	//             24.  This routine makes sure that one of these values is
	//             used (whichever is most appropriate for the specified
	//             nBPP).

	virtual void Serialize(CArchive& ar);
	// --- In :	ar : A CArchive object to serialize to or from
	// --- Out : 
	// --- Returns :
	// --- Effect : Inits load or save of the COXDIB
	
	BOOL Read(LPCTSTR pszPath);
	// --- In :	pszPath : Path specification of DIB file
	// --- Out : 
	// --- Returns :TRUE if successful, else FALSE or CFileException
	// --- Effect : 
	
	BOOL Write(LPCTSTR pszPath);
	// --- In :	pszPath : Path specification of DIB file
	// --- Out : 
	// --- Returns :TRUE if successful, else FALSE or CFileException
	// --- Effect : 
	
	BOOL Read(CFile* pDIBFile);
	// --- In :	pDIBFile : an open DIB file
	// --- Out : 
	// --- Returns : TRUE if successful, else FALSE or CFileException
	// --- Effect : 
	
	BOOL Write(CFile* pDIBFile);
	// --- In :	pDIBFile : an open DIB file
	// --- Out : 
	// --- Returns : TRUE if successful, else FALSE or CFileException
	// --- Effect : 

	BOOL Read(CArchive& ar);
	// --- In :	ar: the archive used to read DIB
	// --- Out : 
	// --- Returns :TRUE if successful, else FALSE or exception
	// --- Effect : 

	BOOL Write(CArchive& ar);
	// --- In :	ar: the archive used to write DIB
	// --- Out : 
	// --- Returns :TRUE if successful, else FALSE or exception
	// --- Effect : 

	virtual ~COXDIB();
	// --- In  :
	// --- Out : 
	// --- Returns :
	// --- Effect : Destructor of object

	// Michael
	HANDLE GetDIBHandle();

// Diagnostics --------------------------------------------------------------
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:      
	BOOL InitPalette(LPSTR lpbi);
	DWORD ReadHuge(CArchive& ar, void FAR* lpBuffer, DWORD dwCount);
	void WriteHuge(CArchive& ar, const void FAR* lpBuffer, DWORD dwCount);
	UINT CalcSize(DWORD cbTotal, const void FAR* lpStart);
	HDIB WINAPI CopyHandle (HDIB hDIB, DWORD dwExtraBytes = 0);
	PDIB ReadBitmapInfo(CArchive& ar);

private:
	HDIB Detach();
                   
};

#endif
// ==========================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -