首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >uiimage到iplimage

uiimage到iplimage
EN

Stack Overflow用户
提问于 2011-04-04 18:07:16
回答 1查看 1K关注 0票数 1

我尝试将黑白UIImage转换为IplImage,但从控制台给出了这些。ı不能做什么呢?

代码语言:javascript
复制
CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 16 bits/pixel; 1-component color space; kCGImageAlphaPremultipliedLast; 84 bytes/row.

CGContextDrawImage: invalid context 0x0.


notaImage = [UIImage imageWithCGImage:drawImage];
         //UIImageWriteToSavedPhotosAlbum(notaImage, self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo:), nil);
         vec_iphone.push_back(notaImage);    
         CGImageRef i_Ref = notaImage.CGImage;

         CGColorSpaceRef color_S = CGColorSpaceCreateDeviceGray();
             // Creating temporal IplImage for drawing
         IplImage *nota_img = cvCreateImage(
                                  cvSize(notaImage.size.width,notaImage.size.height), IPL_DEPTH_8U, 1
                                 );
             // Creating CGContext for temporal IplImage
         CGContextRef c_Ref = CGBitmapContextCreate(
                                        nota_img->imageData, nota_img->width, nota_img->height,
                                        nota_img->depth, nota_img->widthStep,
                                        color_S, kCGImageAlphaPremultipliedLast|kCGBitmapByteOrderDefault
                                      );

             // Drawing CGImage to CGContext
             CGContextDrawImage(
                                c_Ref,
                                CGRectMake(0, 0, notaImage.size.width, notaImage.size.height),
                                i_Ref
                                );

             //


             vec_images.push_back(nota_img);
             CGContextRelease(c_Ref);
             CGColorSpaceRelease(color_S);
             CGImageRelease(i_Ref);
EN

回答 1

Stack Overflow用户

发布于 2011-04-04 22:14:08

由于您的输入图像是灰色的,因此上下文格式不包含任何alpha通道,因此使用kCGImageAlphaPremultipliedLast是不正确的。请尝试使用kCGImageAlphaNone

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5537021

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档