本文介绍了如何在c ++中将1d图像缓冲区转换为2d图像缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何在C ++中将1d图像缓冲区转换为2d图像缓冲区?

我有一个d图像缓冲区,我需要转换为2d指针?

Hi,,

How to convert 1d image buffer to 2d image buffer in c++ ?

i have one d image buffer, i need to convert in to 2d pointer??

unsigned char * OneDArray to unsigned char ** TwoDArray ??



有任何建议,

有人吗?



Any suggestion ,

Any one?

推荐答案

#define PixelSize 3    // Assuming 24 bit color
#define Width     100  // Assuming image width is 100 pixels
#define Height    100  // Assuming image height is 100 pixels

// This fucntion returns a pointer to the first pixel in a line
unsigned char * GetLine(unsigned char * OneDArray, int y)
{
   return OneDArray + (y * Width * PixelSize);
}

// This function return a pointer to a pixel
unsigned char * GetPixel(unsigned char * OneDArray, int x, int y)
{
   return OneDArray + (((y * Width) + x) * PixelSize);
}


这篇关于如何在c ++中将1d图像缓冲区转换为2d图像缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-21 16:32