Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7192247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:54:04+00:00 2026-05-28T19:54:04+00:00

This is my first assignment about image processing. I’m assuming index of each pixel

  • 0

This is my first assignment about image processing. I’m assuming index of each pixel on output image are represented as matrix below:

00 01 02 03 04 05

10 11 12 13 14 15

20 21 22 23 24 25

At each index of output image I have different color to draw on. For ex, at index 00 I have redcolor available to put there and so on with other indexes. My question is how can I draw these color into the indexes to create the output image?

Update

This is what I have right now:

 inputImgAvg //Image for processing
 CGContextRef context = UIGraphicsGetCurrentContext();

 float  yy = groutW / 2;            // skip over grout on edge
     float stride =(int) (tileW + groutW +0.5);
        for(int y=0; y<tilesY; y++) {               //Number tile in Y direction
            float xx = groutW / 2 ;         // skip over grout on edge
            for(int x=0; x<tilesX; x++) {
                tileRGB = [inputImgAvg colorAtPixel:CGPointMake(x,y)];

                //Right here I'm checking tileRGB with list of available color
                //Find out the closest color 
                //Now i'm just checking with greenColor

                // best matching tile is found in idx position in vector;
                // scale and copy it into proper location in the output
                CGContextSetFillColor(context, CGColorGetComponents( [[UIColor greenColor] CGColor]));

But I got this error. Can you point out what did I do wrong?

<Error>: CGContextSetFillColor: invalid context 0x0
<Error>: CGContextFillRects: invalid context 0x0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:54:06+00:00Added an answer on May 28, 2026 at 7:54 pm

    This thread answers the question:

    http://www.iphonedevsdk.com/forum/iphone-sdk-development/34247-cgimage-pixel-array.html

    Create a CGContext using CGBitmapContextCreate, which lets you supply the data for the image. You can then write pixels into the data using a pointer and setting the bytes yourself.

    Once you are done, use UIGraphicsGetImageFromCurrentContext() or equivalent to grab the context data out into a UIImage object.

    If that all seems a bit low-level, another option would be to just create a CGContext and draw 1×1 rectangles into it. It won’t be amazingly fast, but it won’t be as slow as you think because CG functions are all pure C and any redundancy gets optimised out by the compiler:

    //create drawing context
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, 0.0f);
    CGContextRef context = UIGraphicsGetCurrentContext();  
    
    //draw pixels
    for (int x = 0; x < width; x++)
    {
       for (int y = 0; y < height; y++)
       {
          CGContextSetFillColor( ... your color here ... );
          CGContextFillRect(context, CGRectMake(x, y, 1.0f, 1.0f));
       }
    }
    
    //capture resultant image
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using NSURLConnection as listed below. I have three questions about this class. When
I have question regarding polymorphism about its assignment statement, for Example this is The
This is a homework assignment and my first experience using RegEx. I am starting
First of all this is a homework assignment so I'm looking for assistance, not
This first bit works: $my_id = 617; $post_id_7 = get_post($my_id); $title = $post_id_7->post_excerpt; echo
Saw this piece of code in a Ruby on Rails book. This first one
problem euler #5 i found the solution but i don't know why this first
Using Dozer to map two objects, I have: /** /* This first class uses
#include <iostream> using namespace std; // This first class contains a vector and a
this my first shot at this awesome new (to me) programmers site, I hope

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.