How do you draw a single pixel on a CGContextRef

Discussion in 'iOS Programming' started by mistasparkaru, Apr 19, 2010.

  1. mistasparkaru macrumors newbie

    Joined:
    Apr 19, 2010
    #1
    Hello everybody, i am very new to iphone programming so I have probably got the wrong end of the stick.

    I can draw simple graphcs by doing a:

    CGContextRef context = UIGraphicsGetCurrentContext();

    then i can do a:

    CGContextMoveToPoint(context, 10, 10);
    CGContextAddLineToPoint(context, 20,20);
    CGContextDrawPath(context,kCGPathFillStroke);

    etc to draw simple shapes but where is the setpixel? I want to create a mandlebrot viewer as a learning excersize but i cant get very far without setpixel.


    also, is there a simple way of passing a color to CGContextSetFillColorWithColor? without casting a UIcolor and CGColorRef?
     
  2. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #2
    You can use CGContextFillRect with a rect size (width, height) of 1.0.

    You can get a CGBitmapContext, and write directly into it's memory.
     
  3. mistasparkaru thread starter macrumors newbie

    Joined:
    Apr 19, 2010
    #3
    Do you have any CGBitmapConext examples?

    why is doing a putpixel so complicated?
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Because in a lot of contexts that makes no sense. What is a pixel in a resolution independent vector context?
     

Share This Page