[英]Copying data from a raw image using c++ and objective c
I'm getting a callback from a library that gives me a raw image which is 640*480*4 R8G8B8A8 我正在从一个库中获取一个回调,该回调为我提供了640 * 480 * 4 R8G8B8A8的原始图像
I did copying it into another buffer then I try to skip the 4th buffer because my framework works only with R8G8B8 我确实将其复制到另一个缓冲区中,然后尝试跳过第四个缓冲区,因为我的框架仅适用于R8G8B8
I tried to debug and see the bytes in the variable d, but the bytes are all garbage. 我尝试调试并查看变量d中的字节,但这些字节都是垃圾。
-(void)onRawImageBuffer:(NSData * _Nonnull)data withWidth:(int)width andHeight:(int)height andBytesPerPixel:(int)bytesPerPixel;
{
NSUInteger len = [data length];
memcpy(m_CopyData, [data bytes], len);
for(int i =0; i < 640*480*3;i++)
{
if ( i%4 == 3 )
continue;
else{
m_FrameData[i] = m_CopyData[i];
}
}
NSData* d = [NSData dataWithBytes:(const void *)m_FrameData length:640*480*3];
Input::SensorInput::getSingleton()->setVideoData( m_FrameData );
}
width * height * 4
; 您的循环必须仍为width * height * 4
; m_FrameData
; 您尚未分配m_FrameData
; bytesPerPixel
; 您没有考虑bytesPerPixel
; continue;
still advance i
by one, you must use two indices; 仍将i
提前一,您必须使用两个索引;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.