如何在ios中从CGImage中读取RBG-像素值[英] How To Read RBG-Pixel values from CGImage in ios

本文是小编为大家收集整理的关于如何在ios中从CGImage中读取RBG-像素值的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

本文来自:IT宝库(https://www.itbaoku.cn)

我如何通过cgimagea读取如何通过cgimagea读取RGB像素,也可以将其分配给UIIMAGE

推荐答案

要使用Monotouch读取RGB像素值您可以使用以下帖子的答案中发布的代码(对我来说正常):

检索uiimage(monotouch)的像素alpha值(monotouch)

您还可以找到以下帖子有用:

iOS

的透明pngs

这是指向卷积过滤器的矿山的工作实现的链接,它读取和解雇像素的RGB值(在iOS上,所有带有Alpha通道的iOS图像都存储在超级alpha格式中):

) 在单调?

记住,即使您使用技巧创建仅1x1像素的位图上下文,读取像素值也很慢.

其他推荐答案

此链接位图用于处理由像素数据定义的图像.

yourimage= new Bitmap(@"image address", true);

    int x, y;

    // Loop through the images
    for(x=0; x<yourimage.Width; x++)
    {
        for(y=0; y<yourimage.Height; y++)
        {
            //Get Pixel Color
            Color pixelColor = image1.GetPixel(x, y);
            Color yourColor = Color.FromArgb(pixelColor.R, 0, 0);
            //Set Pixel Color
            yourimage.SetPixel(x, y, yourColor );

本文地址:https://www.itbaoku.cn/post/1640394.html

问题描述

How I can Read the RGB-Pixel by Pixel values from CGImagea also after how to assign it to UIImage

推荐答案

To read RGB pixel values with MonoTouch you can use the code posted in the answer to the following post (works fine for me):

Retrieving a pixel alpha value for a UIImage (MonoTouch)

You can also find the following post useful:

Transparent PNGs in Monotouch for iOS

And here is a link to a working implementation of mine of a convolution filter, that reads and demultiplies the pixel's rgb values (on iOS all images with alpha channel are stored in a premultiplied-alpha format):

How to Optimize this Image convolution filter Method in MonoTouch?

Remember that reading pixel values is very slow, even if you use the trick to create a bitmap context of only 1x1 pixels.

其他推荐答案

according this link Bitmap is used to work with images defined by pixel data.

yourimage= new Bitmap(@"image address", true);

    int x, y;

    // Loop through the images
    for(x=0; x<yourimage.Width; x++)
    {
        for(y=0; y<yourimage.Height; y++)
        {
            //Get Pixel Color
            Color pixelColor = image1.GetPixel(x, y);
            Color yourColor = Color.FromArgb(pixelColor.R, 0, 0);
            //Set Pixel Color
            yourimage.SetPixel(x, y, yourColor );