相关疑难解决方法(0)

如何从UIImage(Cocoa Touch)或CGImage(Core Graphics)获取像素数据?

我有一个UIImage(Cocoa Touch).从那以后,我很高兴得到一个CGImage或其他你想要的东西.我想写这个函数:

- (int)getRGBAFromImage:(UIImage *)image atX:(int)xx andY:(int)yy {
  // [...]
  // What do I want to read about to help
  // me fill in this bit, here?
  // [...]

  int result = (red << 24) | (green << 16) | (blue << 8) | alpha;
  return result;
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

cocoa cocoa-touch core-graphics

196
推荐指数
9
解决办法
14万
查看次数

Objective-c - 在图像中获得最少使用和最常用的颜色

我试图获得最少使用的颜色,以及MP3文件的专辑插图中用于音乐播放应用程序的最常用颜色.我需要颜色来做一个像新的itunes 11的效果.菜单的背景颜色是最常用的颜色,最少使用的颜色是歌曲标签和艺术家名称的颜色.我在用

`- (UIColor*) getPixelColorAtLocation:(CGPoint)point {
    UIColor* color = nil;
    CGImageRef inImage = self.image.CGImage;
    // Create off screen bitmap context to draw the image into. Format ARGB is 4 bytes for each pixel: Alpa, Red, Green, Blue
    CGContextRef cgctx = [self createARGBBitmapContextFromImage:inImage];
    if (cgctx == NULL) { return nil; /* error */ }

    size_t w = CGImageGetWidth(inImage);
    size_t h = CGImageGetHeight(inImage);
    CGRect rect = {{0,0},{w,h}}; 

    // Draw the image to the bitmap context. Once we draw, the memory
    // allocated …
Run Code Online (Sandbox Code Playgroud)

itunes objective-c uicolor ios

25
推荐指数
2
解决办法
1万
查看次数

修剪UIImage边框

这是我想修剪的图像的一个例子.我想摆脱图像周围的边框(在这种情况下是顶部和底部黑条).

UIImage修剪

我在Github上找到了一个库:CKImageAdditions,但它似乎不起作用.当我传入UIColor(RGB颜色)时,它只返回相同的图像.

我可以找到许多示例和类别类来修剪UIImage,任何透明像素作为边框,但在这种情况下我需要修剪黑色.我已经对我的图像中的颜色进行了采样,它们的颜色值确实是255,但它似乎与上面的库所寻找的不匹配.

有没有人有他们使用的图书馆或任何见解?我搜索和搜索了CKImageAdditions,这是我唯一可以找到广告用颜色修剪的东西(虽然不幸的是在我的情况下不起作用).

c objective-c uiimage cgimage ios

5
推荐指数
1
解决办法
1378
查看次数

标签 统计

ios ×2

objective-c ×2

c ×1

cgimage ×1

cocoa ×1

cocoa-touch ×1

core-graphics ×1

itunes ×1

uicolor ×1

uiimage ×1