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

📄 datamanager.cpp

📁 上述是VIsualc++ 数字图像处理一书的源码
💻 CPP
字号:
#include "stdafx.h"
#include "DataManager.h"


/************************************************************************/
/* 构造函数                                                             */
/************************************************************************/
DataManager::DataManager()
{
	maxIndex = 0;
}

DataManager::~DataManager()
{
	// 释放所有数据
}

/************************************************************************/
/* 添加图像数据                                                                     */
/************************************************************************/
ImageData *DataManager::AddData(unsigned char* data,int imgWidth,int imgHeight,int bytes,CDocument *doc)
{
	if(data == NULL) return NULL;
	
	ImageData id;
	id.bytes = bytes;
	id.data = new unsigned char[imgWidth * imgHeight * bytes / 8];
	memcpy(id.data,data,sizeof(unsigned char) * imgWidth * imgHeight * bytes / 8);  // 拷贝输入的数据

	id.imgWidth = imgWidth;
	id.imgHeight = imgHeight;
	id.index = maxIndex;
	id.coreDoc = doc;
	id.use = 0;  // 当前使用数据

	switch(id.bytes)
	{
	case 8:
		id.format = IMAGE_FORMAT_GRAY8;
		break;
	case 24:
		id.format = IMAGE_FORMAT_RGB24;
		break;
	}

	imageList.Append(&id,sizeof(ImageData));
	
	maxIndex ++;

	return (ImageData*)imageList.GetLastInfo();

}

/************************************************************************/
/* 删除一个图像                                                         */
/************************************************************************/
void DataManager::RemoveData(int index)
{

}

/************************************************************************/
/* 删除一个图像                                                         */
/************************************************************************/
void DataManager::RemoveData(ImageData *id)
{
	// 删除一个节点上的数据
}

/************************************************************************/
/* 获得一幅图像                                                         */
/************************************************************************/
ImageData* DataManager::GetData(int index)
{
	return NULL;
}

⌨️ 快捷键说明

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