几何尺寸与公差论坛

 找回密码
 注册
查看: 861|回复: 1

convert hobject to cogimage using the above code, but get the wrong length

[复制链接]
发表于 2023-2-11 15:32:57 | 显示全部楼层 |阅读模式
try to convert hobject to cogimage using the above code, but get the wrong length, could you help to check   the line - " long length = pixelMemory.Stride * pixelMemory.Height*sizeof(short);" and fix this line?
 楼主| 发表于 2023-2-11 15:33:22 | 显示全部楼层
calculates the size (in bytes) of the image data that needs to be copied from the source sourPtr to the destination pixelMemory.Scan0. It assumes that the image data is stored as a contiguous block of memory, where each pixel is represented by a single 16-bit (short) value, and the pixel data is stored row-by-row with a certain "stride" value indicating the number of bytes per row.

If you are experiencing issues with this line of code, it could be due to the following reasons:

    The pixelMemory.Stride value is not equal to pixelMemory.Width * sizeof(short), indicating that the row stride of the pixel data is not what is expected. If this is the case, you may need to modify the code to handle the specific layout of the image data in sourPtr.

    The sourPtr pointer is not valid, or does not point to a valid block of memory containing image data. In this case, you will need to ensure that the sourPtr pointer is correctly initialized and points to a block of memory that contains valid image data.

    The length variable is not correctly calculated, which could cause memory access errors or other issues. You may need to modify the calculation of length to ensure that it is correctly calculated based on the actual size and layout of the image data.

Without more information, it is difficult for me to suggest specific solutions to the problem. If you could provide more information about the error messages or other issues you are experiencing, or provide more context about the specific image data you are trying to convert, I may be able to offer more specific advice.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-22 13:00 , Processed in 0.034725 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表