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

📄 jpeg.h

📁 本光盘包含了《精通Visual C++图像处理编程(第3版)》一书中全部的源代码、示例程序的可执行文件以及一些供图像处理测试用的图像文件。
💻 H
字号:
// Jpeg.h: interface for the CJpeg class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_JPEG_H__63087660_0165_11D3_9481_000021003EA5__INCLUDED_)
#define AFX_JPEG_H__63087660_0165_11D3_9481_000021003EA5__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Dib.h"

class CJpeg  
{
public:
	CJpeg();
	CJpeg(CDib *pDib);
	virtual ~CJpeg();

// function
public:
	// Get CDib
	CDib * GetDib()
	{
		return m_pDib;
	}
	//Set CDib
	BOOL SetDib(CDib *pDib)
	{
		if (pDib == NULL)
			return FALSE;

		if (m_pDib != NULL)
			delete m_pDib;

		m_pDib = pDib->Clone();

		return (m_pDib != NULL);
	}
	// Load JPEG file
	BOOL Load(LPCSTR lpstrFileName);
	// save JPEG file
	BOOL Save(LPCSTR lpstrFileName, 
			  CDib* pDib = NULL,
			  BOOL bColor = TRUE,
			  int nQuality = 75);
	// get error string
	CString GetErrorString();

private:
	////////////////////////////////////////////////////////////////
	// read a JPEG file to an RGB buffer - 3 bytes per pixel
	// returns a ptr to a buffer .
	BYTE* ReadJPEGFile(LPCSTR lpstrFileName, UINT *uWidth, UINT *uHeight);
	////////////////////////////////////////////////////////////////
	// write a JPEG file from a 3-component, 1-byte per component buffer
	BOOL WriteJPEGFile(LPCTSTR lpstrFileName,	// path
					   BYTE *dataBuf,			// RGB buffer
					   UINT width,				// pixels
					   UINT height,				// rows
					   BOOL color,				// TRUE = RGB
												// FALSE = Grayscale
    				   int quality);			// 0 - 100

	////////////////////////////////////////////////////////////////
	// allocates a DWORD-aligned buffer, copies data buffer
	// caller is responsible for delete []'ing the buffer
	BYTE* MakeDwordAlign(BYTE *dataBuf,			// input buf
						 UINT widthPix,				// input pixels
						 UINT height,				// lines
						 UINT *uiOutWidthBytes);	// new width bytes
	// free allocate memory
	void FreeBuffer(BYTE *Buffer);
	////////////////////////////////////////////////////////////////
	// if you have a DWORD aligned buffer, this will copy the
	// RGBs out of it into a new buffer. new width is widthPix * 3 bytes
	// caller is responsible for delete []'ing the buffer
	BYTE *ClearDwordAlign(BYTE *inBuf,				// input buf
						UINT widthPix,				// input size
						UINT widthBytes,			// input size
						UINT height);
	BOOL VertFlipBuf(BYTE * inbuf,						// input buf
				   UINT widthBytes,							// input width bytes
				   UINT height);							// height
	BOOL BGRFromRGB(BYTE *buf,							// input buf
					UINT widthPix,								// width in pixels
					UINT height);								// lines

	// data
	CString m_strJPEGError;

//data
private:
	CDib*	m_pDib;
};

#endif // !defined(AFX_JPEG_H__63087660_0165_11D3_9481_000021003EA5__INCLUDED_)

⌨️ 快捷键说明

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