【发布时间】:2011-10-14 09:19:20
【问题描述】:
由于某种原因,我无法确定我遇到了访问冲突。
memcpy_s (buffer, bytes_per_line * height, image, bytes_per_line * height);
这是整个功能:
int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height)
{
// this function is used to flip bottom-up .BMP images
UCHAR *buffer; // used to perform the image processing
int index; // looping index
// allocate the temporary buffer
if (!(buffer = (UCHAR *) malloc (bytes_per_line * height)))
return(0);
// copy image to work area
//memcpy(buffer, image, bytes_per_line * height);
memcpy_s (buffer, bytes_per_line * height, image, bytes_per_line * height);
// flip vertically
for (index = 0; index < height; index++)
memcpy(&image[((height - 1) - index) * bytes_per_line], &buffer[index * bytes_per_line], bytes_per_line);
// release the memory
free(buffer);
// return success
return(1);
} // end Flip_Bitmap
整个代码: http://pastebin.com/udRqgCfU
要运行它,您需要源目录中的 24 位位图。 这是较大代码的一部分,我正在尝试使 Load_Bitmap_File 函数工作...... 那么,有什么想法吗?
【问题讨论】:
-
您确定
image具有广告尺寸吗?并且这两个尺寸参数是否正确传递? -
你不需要那个临时缓冲区
-
我认为问题出在
image- 而不是bytes_per_line * height。 -
是读写访问冲突吗?
-
将
biSizeImage与您用bytes_per_line * height计算的大小进行比较。举报我们
标签: c++ access-violation memcpy