English 中文(简体)
创建全球疫苗和免疫联盟原始数据
原标题:Creating UIImage from raw RGBA data

我一直试图将阿根廷、阿根廷、阿根廷、巴西、加拿大、法国、德国、意大利、日本、意大利、日本、意大利、挪威、波兰、葡萄牙、波兰、葡萄牙、罗马尼亚、罗马尼亚、西班牙、瑞典、瑞士、瑞典、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞典、瑞士、瑞士、瑞典、瑞士、瑞士、瑞典、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞典、瑞典、瑞士、瑞士、瑞典、瑞士、瑞士、瑞士、瑞典、瑞士、瑞士、瑞士、瑞典、瑞士、瑞典、瑞士、瑞士、瑞典、瑞典、瑞士、瑞士、瑞典、瑞士、瑞士、瑞典、瑞典、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞典、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、瑞士、 我的法典如下:

/*height and width are integers denoting the dimensions of the image*/
unsigned char *rawData = malloc(width*height*4);

for (int i=0; i<width*height; ++i) 
{
    rawData[4*i] = <red_val>;
    rawData[4*i+1] = <green_val>;
    rawData[4*i+2] = <blue_val>;
    rawData[4*i+3] = 255;
}


/*I Have the correct values displayed
    - ensuring the rawData is well populated*/

NSLog(@"(%i,%i,%i,%f)",rawData[0],rawData[1],rawData[2],rawData[3]/255.0f);
NSLog(@"(%i,%i,%i,%f)",rawData[4],rawData[5],rawData[6],rawData[7]/255.0f);
NSLog(@"(%i,%i,%i,%f)",rawData[8],rawData[9],rawData[10],rawData[11]/255.0f);



CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, 
                                                          rawData, 
                                                          width*height*4, 
                                                          NULL);

int bitsPerComponent = 8;
int bitsPerPixel = 32;
int bytesPerRow = 4*width;
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
CGImageRef imageRef = CGImageCreate(width,
                                    height,
                                    8,
                                    32,
                                    4*width,colorSpaceRef,
                                    bitmapInfo,
                                    provider,NULL,NO,renderingIntent);
/*I get the current dimensions displayed here */
NSLog(@"width=%i, height: %i", CGImageGetWidth(imageRef),
      CGImageGetHeight(imageRef) );
UIImage *newImage = [UIImage imageWithCGImage:imageRef];
/*This is where the problem lies. 
  The width, height displayed are of completely different dimensions
  viz. the width is always zero and the height is a very huge number */

NSLog(@"resultImg width:%i, height:%i",
          newImage.size.width,newImage.size.height);


return newImage;

我得到的产出图像是零宽度的图像,高度为1080950784(假设我的意外高和宽度为240和240)。 我一直试图这样做,并检查了许多相关论坛,例如:,说明如何去做,但几乎没有成功。

最佳回答

解决该问题是我们大家所忽视的极具讽刺意味的错误。 聚二氯乙烯作为浮体储存,而不是燃烧。

提 出

NSLog(@"resultImg width:%f, height:%f",
          newImage.size.width,newImage.size.height);

相反。 图像规模已经正确转移。

问题回答

现在这个问题已经解决。 我看到了我所希望的图像,但我仍然无法说明为什么宽度和高度不同。 从根本上说,方案没有什么错误。 唯一的问题是 w和高。

我刚刚独立地核实了这一问题,我认为应该把它作为 Apple子来报告。 <0>+(UIImage)image WithCGImage: 确实将源代码的宽度和高度适当转让至<代码>UIImage。





相关问题
Resources for Image Recognition

I am looking for a recommendation for an introduction to image processing algorithms (face and shape recognition, etc.) and wondered if anyone had an good recommendations, either for books, ...

Good reference book for digital image processing? [closed]

I am learning digital image processing on my own and would like recomendations on good reference books. If you know of books to definately stay away from that would be useful as well. Thanks

Python Tesseract can t recognize this font

I have this image: I want to read it to a string using python, which I didn t think would be that hard. I came upon tesseract, and then a wrapper for python scripts using tesseract. So I started ...

What s the quickest way to parallelize code?

I have an image processing routine that I believe could be made very parallel very quickly. Each pixel needs to have roughly 2k operations done on it in a way that doesn t depend on the operations ...

Computing object statistics from the second central moments

I m currently working on writing a version of the MATLAB RegionProps function for GNU Octave. I have most of it implemented, but I m still struggling with the implementation of a few parts. I had ...

Viola-Jones face detection claims 180k features

I ve been implementing an adaptation of Viola-Jones face detection algorithm. The technique relies upon placing a subframe of 24x24 pixels within an image, and subsequently placing rectangular ...

热门标签