// BitmapEx.cpp: implementation of the CBitmapEx class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "BitmapEx.h"
#include <io.h>
#include <stdio.h>
#include <tchar.h>
#include <stdlib.h>
#include <math.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBitmapEx::CBitmapEx()
{
// Init members
m_lpData = NULL;
m_dwSize = 0;
m_iPaletteEntries = 0;
m_ResampleMode = RM_NEARESTNEIGHBOUR;
m_ColorMode = CM_RGB;
m_lpFire = NULL;
m_pFireBitmap = NULL;
m_lpWaterHeightField1 = NULL;
m_lpWaterHeightField2 = NULL;
m_bWaterFlip = FALSE;
m_iDamp = 5;
m_iLightModifier = 3;
m_pWaterBitmap = NULL;
m_lpSmokeField = NULL;
m_pSmokeBitmap = NULL;
}
CBitmapEx::~CBitmapEx()
{
// Deinit members
if (m_lpData != NULL)
{
free(m_lpData);
m_lpData = NULL;
}
if (m_lpFire != NULL)
{
free(m_lpFire);
m_lpFire = NULL;
}
if (m_pFireBitmap != NULL)
{
delete m_pFireBitmap;
m_pFireBitmap = NULL;
}
if (m_lpWaterHeightField1 != NULL)
{
free(m_lpWaterHeightField1);
m_lpWaterHeightField1 = NULL;
}
if (m_lpWaterHeightField2 != NULL)
{
free(m_lpWaterHeightField2);
m_lpWaterHeightField2 = NULL;
}
if (m_pWaterBitmap != NULL)
{
delete m_pWaterBitmap;
m_pWaterBitmap = NULL;
}
if (m_lpSmokeField != NULL)
{
free(m_lpSmokeField);
m_lpSmokeField = NULL;
}
if (m_pSmokeBitmap != NULL)
{
delete m_pSmokeBitmap;
m_pSmokeBitmap = NULL;
}
}
void CBitmapEx::Create(long width, long height)
{
// Deinit members
if (m_lpData != NULL)
{
free(m_lpData);
m_lpData = NULL;
}
// Format BITMAPINFOHEADER info
m_iBpp = _BITS_PER_PIXEL_32 >> 3;
memset(&m_bih, 0, sizeof(BITMAPINFOHEADER));
m_bih.biSize = sizeof(BITMAPINFOHEADER);
m_bih.biWidth = max(0, width);
m_bih.biHeight = max(0, height);
m_bih.biPlanes = 1;
m_bih.biBitCount = (WORD)(m_iBpp << 3);
m_iPaletteEntries = 0;
m_iPitch = m_bih.biWidth * m_iBpp;
m_dwSize = m_iPitch * m_bih.biHeight;
m_lpData = (LPBYTE)malloc(m_dwSize*sizeof(BYTE));
// Format BITMAPFILEHEADER info
memset(&m_bfh, 0, sizeof(BITMAPFILEHEADER));
m_bfh.bfType = 'MB';
m_bfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + m_dwSize;
m_bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
}
void CBitmapEx::Create(CBitmapEx& bitmapEx)
{
// Check for valid bitmap
if (bitmapEx.IsValid())
{
// Deinit members
if (m_lpData != NULL)
{
free(m_lpData);
m_lpData = NULL;
}
// Calculate bitmap params
m_iBpp = bitmapEx.GetBpp() >> 3;
m_iPitch = bitmapEx.GetPitch();
memcpy(&m_bfh, bitmapEx.GetFileInfo(), sizeof(BITMAPFILEHEADER));
memcpy(&m_bih, bitmapEx.GetInfo(), sizeof(BITMAPINFOHEADER));
m_dwSize = bitmapEx.GetSize();
m_lpData = (LPBYTE)malloc(m_dwSize*sizeof(BYTE));
memcpy(m_lpData, bitmapEx.GetData(), m_dwSize*sizeof(BYTE));
m_iPaletteEntries = bitmapEx.GetPaletteEntries();
memcpy(m_lpPalette, bitmapEx.GetPalette(), m_iPaletteEntries*sizeof(RGBQUAD));
m_ResampleMode = bitmapEx.GetResampleMode();
}
}
void CBitmapEx::Create(CBitmapEx* pBitmapEx)
{
// Check for valid bitmap
if ((pBitmapEx != NULL) && (pBitmapEx->IsValid()))
{
// Deinit members
if (m_lpData != NULL)
{
free(m_lpData);
m_lpData = NULL;
}
// Calculate bitmap params
m_iBpp = pBitmapEx->GetBpp() >> 3;
m_iPitch = pBitmapEx->GetPitch();
memcpy(&m_bfh, pBitmapEx->GetFileInfo(), sizeof(BITMAPFILEHEADER));
memcpy(&m_bih, pBitmapEx->GetInfo(), sizeof(BITMAPINFOHEADER));
m_dwSize = pBitmapEx->GetSize();
m_lpData = (LPBYTE)malloc(m_dwSize*sizeof(BYTE));
memcpy(m_lpData, pBitmapEx->GetData(), m_dwSize*sizeof(BYTE));
m_iPaletteEntries = pBitmapEx->GetPaletteEntries();
memcpy(m_lpPalette, pBitmapEx->GetPalette(), m_iPaletteEntries*sizeof(RGBQUAD));
m_ResampleMode = pBitmapEx->GetResampleMode();
}
}
void CBitmapEx::Load(LPTSTR lpszBitmapFile)
{
// Check for valid .BMP file path
if (lpszBitmapFile != NULL)
{
// Open .BMP file
FILE* file = _tfopen(lpszBitmapFile, _T("rb"));
if (file != NULL)
{
// Deinit members
if (m_lpData != NULL)
{
free(m_lpData);
m_lpData = NULL;
}
// Read BITMAPFILEHEADER info
fread(&m_bfh, 1, sizeof(BITMAPFILEHEADER), file);
// Read BITMAPINFOHEADER info
fread(&m_bih, 1, sizeof(BITMAPINFOHEADER), file);
// Calculate pitch
m_iBpp = m_bih.biBitCount >> 3;
m_iPitch = m_iBpp * m_bih.biWidth;
while ((m_iPitch & 3) != 0)
m_iPitch++;
// Check for bit-depth (8, 16, 24 and 32bpp only)
if (m_bih.biBitCount >= 8)
{
if (m_bih.biBitCount == 8)
{
// Calculate palette entries
m_iPaletteEntries = m_bih.biClrUsed;
if (m_iPaletteEntries == 0)
m_iPaletteEntries = 256;
// Read palette info
fread(m_lpPalette, m_iPaletteEntries, sizeof(RGBQUAD), file);
}
// Read image data
m_dwSize = m_iPitch * m_bih.biHeight;
m_lpData = (LPBYTE)malloc(m_dwSize*sizeof(BYTE));
fread(m_lpData, m_dwSize, sizeof(BYTE), file);
// Convert to 32bpp bitmap
_ConvertTo32Bpp();
}
// Close .BMP file
fclose(file);
}
}
}
void CBitmapEx::Load(LPBYTE lpBitmapData)
{
// Check for valid bitmap data buffer
if (lpBitmapData != NULL)
{
// Deinit members
if (m_lpData != NULL)
{
free(m_lpData);
m_lpData = NULL;
}
// Read BITMAPFILEHEADER info
memcpy(&m_bfh, lpBitmapData, sizeof(BITMAPFILEHEADER));
// Read BITMAPINFOHEADER info
memcpy(&m_bih, lpBitmapData+sizeof(BITMAPFILEHEADER), sizeof(BITMAPINFOHEADER));
// Calculate pitch
m_iBpp = m_bih.biBitCount >> 3;
m_iPitch = m_iBpp * m_bih.biWidth;
while ((m_iPitch & 3) != 0)
m_iPitch++;
// Check for bit-depth (8, 16, 24 and 32bpp only)
if (m_bih.biBitCount >= 8)
{
if (m_bih.biBitCount == 8)
{
// Calculate palette entries
m_iPaletteEntries = m_bih.biClrUsed;
if (m_iPaletteEntries == 0)
m_iPaletteEntries = 256;
// Read palette info
memcpy(m_lpPalette, lpBitmapData+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER), m_iPaletteEntries*sizeof(RGBQUAD));
}
// Read image data
m_dwSize = m_iPitch * m_bih.biHeight;
m_lpData = (LPBYTE)malloc(m_dwSize*sizeof(BYTE));
memcpy(m_lpData, lpBitmapData+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+m_iPaletteEntries*sizeof(RGBQUAD), m_dwSize*sizeof(BYTE));
// Convert to 32bpp bitmap
_ConvertTo32Bpp();
}
}
}
void CBitmapEx::Load(HBITMAP hBitmap)
{
// Check for valid bitmap handle
if (hBitmap != NULL)
{
// Deinit members
if (m_lpData != NULL)
{
free(m_lpData);
m_lpData = NULL;
}
// Get bitmap info
BITMAP bmp;
GetObject(hBitmap, sizeof(BITMAP), &bmp);
// Check for valid bitmap format (16, 24 and 32bpp only)
if (bmp.bmBitsPixel > 8)
{
// Get bitmap data
m_iBpp = bmp.bmBitsPixel >> 3;
m_iPitch = bmp.bmWidthBytes;
m_dwSize = bmp.bmHeight * m_iPitch;
m_lpData = (LPBYTE)malloc(m_dwSize*sizeof(BYTE));
GetBitmapBits(hBitmap, m_dwSize*sizeof(BYTE), m_lpData);
// Format BITMAPFILEHEADER info
memset(&m_bfh, 0, sizeof(BITMAPFILEHEADER));
m_bfh.bfType = 'MB';
m_bfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + m_dwSize;
m_bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
// Format BITMAPINFOHEADER info
memset(&m_bih, 0, sizeof(BITMAPINFOHEADER));
m_bih.biSize = sizeof(BITMAPINFOHEADER);
m_bih.biWidth = bmp.bmWidth;
m_bih.biHeight = bmp.bmHeight;
m_bih.biPlanes = 1;
m_bih.biBitCount = bmp.bmBitsPixel;
// Convert to 32bpp bitmap
_ConvertTo32Bpp();
FlipVertical
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
在进行VideoNet的程序(在http://www.codeproject.com/Articles/7573/VideoNetb下载的)学习中,发现在进行调试时, 运行到 ConvertRGB2YUV 函数时,在 *y++=( RGB2YUV_YR[*r] +RGB2YUV_YG[*g]+RGB2YUV_YB[*b]+1048576)>>16; 出down掉! 崩溃! 程序每次到这里崩溃,我也崩溃了!后来反复查网上帖子解决该问题: 本资源为:修改了ConvertRGB2YUV出错问题的基于H263协议压缩的VideoNet 视频聊天程序
资源推荐
资源详情
资源评论
收起资源包目录
修改了ConvertRGB2YUV出错问题的基于H263协议压缩的VideoNet 视频聊天程序 (105个子文件)
VideoNet.clw 5KB
BitmapEx.cpp 452KB
GetPic.cpp 32KB
coder.cpp 31KB
convert.cpp 30KB
VideoNetDlg.cpp 29KB
dct.cpp 23KB
复件 convert.cpp 23KB
Recon.cpp 22KB
countbit.cpp 18KB
Sactbls.cpp 12KB
mot_est.cpp 12KB
pred.cpp 12KB
GetVlc.cpp 11KB
GetBlk.cpp 10KB
cdxCRot90DC.cpp 9KB
Tmndec.cpp 9KB
libr263.cpp 8KB
DGlobal.cpp 8KB
DSocket.cpp 7KB
Sac.cpp 7KB
Idct.cpp 7KB
huffman.cpp 6KB
RecordSound.cpp 6KB
PlaySound.cpp 6KB
GetBits.cpp 6KB
VideoCapture.cpp 6KB
YuvToRgb.cpp 5KB
GetHdr.cpp 5KB
stream.cpp 4KB
Idctref.cpp 4KB
Mixer.cpp 4KB
Indices.cpp 4KB
rlib.cpp 3KB
quant.cpp 3KB
RequestDlg.cpp 3KB
main.cpp 2KB
ConnectDlg.cpp 2KB
VideoNet.cpp 2KB
复件 VideoNet.cpp 2KB
Volume.cpp 2KB
Global.cpp 1KB
StdAfx.cpp 494B
VideoNet.dsp 10KB
VideoNet.dsw 539B
BitmapEx.h 14KB
cdxCRot90DC.h 12KB
config.h 6KB
struct.h 5KB
def.h 5KB
Tmndec.h 4KB
VideoNetDlg.h 4KB
ctables.h 4KB
DGlobal.h 4KB
decdef.h 3KB
Recon.h 3KB
libr263.h 2KB
GetPic.h 2KB
convert.h 2KB
Sactbls.h 2KB
VideoCapture.h 2KB
rlib.h 2KB
resource.h 2KB
Idct.h 2KB
PlaySound.h 2KB
coder.h 2KB
Global.h 2KB
Indices.h 2KB
DSocket.h 2KB
pred.h 2KB
countbit.h 2KB
GetBlk.h 2KB
RecordSound.h 2KB
GetVlc.h 2KB
GetBits.h 2KB
decstruct.h 2KB
huffman.h 2KB
Sac.h 1KB
GetHdr.h 1KB
Idctref.h 1KB
VideoNet.h 1KB
RequestDlg.h 1KB
mot_est.h 1KB
ConnectDlg.h 1KB
Mixer.h 1KB
owntypes.h 1KB
Volume.h 1KB
StdAfx.h 1KB
quant.h 974B
dct.h 929B
stream.h 890B
h263 2KB
videonet.ico 10KB
VideoNet.ico 1KB
recording.log 13KB
playsound.log 6KB
videocapture.log 0B
main.log 0B
decoder.log 0B
VideoNet.plg 19KB
共 105 条
- 1
- 2
ljh_0728
- 粉丝: 3
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- ### 词向量的介绍、使用技巧和优缺点的文章
- 基于STM32F103CBT6单片机GC65+MP2625+CC1101 GPSTrack模块板硬件(原理图+PCB)工程文件
- ### 通道处理过程模拟概念、优缺点和使用技巧
- ### MyBatis动态SQL介绍说明、使用技巧和优缺点
- 上传下载仿163网盘无刷新文件上传 for Jsp-fileupload-jsp.rar
- VMware Workstation业界非常稳定且安全的桌面虚拟机软件-计算机上运行多个操作系统,支持Windows、DOS等
- 基于STM8L101F3P6单片机+LY2508A33P+CC1100遥控器硬件(原理图+PCB)工程文件.zip
- 上传下载WAP图铃下载系统-unimg.rar
- YTX-0.1.0-Win
- 上传下载ExtJS 2.2 开源网络硬盘系统-dogdisk.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页