我深化发展成像库和我正在与该图像数据的数据类型什么数据类型用于图像数据以避免std:bad_alloc?
挣扎由于图像可以具有可变的数据类型(每像素8位,每像素16位)我想实施我的图像数据的指针到
void* pimage_data;
但是无效*导致各类污秽丑恶的,包括指针算术如
pimage_data = &((unsigned char*)pimage_parent->m_pdata)[offset_y * pimage_parent->m_pitch + offset_x];
我怀疑的东西是不对的,因为当我把它传递给另一个方法
个CImage* roi = CImage::create_image(size_x, size_y, pimage_parent->m_data_type, pimage_data);
CImage* CImage::create_image(int size_x, int size_y, E_DATA_TYPE data_type, void* pimage)
{
assert(size_x > 0);
assert(size_y > 0);
CImage* image = new CImage(size_x, size_y, data_type);
image->m_pdata = pimage;
return image;
}
新收益std::bad_alloc
现在我必须同意这一空白*不会直接导致bad_alloc的,但我敢肯定的东西是错误与它在这里。任何提示?
编辑:
的CImage确实几乎为零
CImage::CImage(int size_x, int size_y, E_DATA_TYPE data_type)
{
assert(size_x > 0);
assert(size_y > 0);
// Copy of the parameter to the class members
this->m_size_x = size_x;
this->m_size_y = size_y;
this->m_data_type = data_type;
this->m_pitch = size_x;
// The ctor simply create a standalone image for now
this->m_pimage_child = NULL;
this->m_pimage_parent = NULL;
}
尺寸为x:746,Y:325
当您拨打新电话时,您正在操作的图像的大小是多少? (什么是'size_x,size_y'?) – GManNickG 2010-01-19 03:01:01
我们可以看到CImage的构造函数吗? – 2010-01-19 04:19:45