Professional Web Applications Themes

Drawing *without* :-) outputting the result to the screen - Mac Programming

Hi, I need to draw a bitmap image (using NSBezierPath...) but do not want to show the result on the screen. Should I still use a subclass of NSView and drawRect or is there a better way to do it? Thank you very much, Loc...

  1. #1

    Default Drawing *without* :-) outputting the result to the screen

    Hi,

    I need to draw a bitmap image (using NSBezierPath...) but do not want
    to show the result on the screen. Should I still use a subclass of
    NSView and drawRect or is there a better way to do it?

    Thank you very much,

    Loc
    Loic Guest

  2. #2

    Default Re: Drawing *without* :-) outputting the result to the screen

    dans l'article google.com, Loic
    BERTRAND fr a crit le 25/10/03 16:33:
     

    You want to use CGBitmapContextCreate

    Eric Guest

  3. #3

    Default Drawing *without* :-) outputting the result to the screen

    Hi Eric,

    Thank you for your help.
    I nevertheless do not feel to confident with these graphicContext.
    Could you be a bit more explicit about the way to do it.

    Moreover couldn't I do it using a NSImageRep directly?

    Merci d'avance,

    Loc

    (I have lots of problems with the Google posts...)



    Eric VERGNAUD <fr> wrote in message news:<BBC18BAA.14657%fr>... 
    >
    > You want to use CGBitmapContextCreate[/ref]
    Loic Guest

  4. #4

    Default Re: Drawing *without* :-) outputting the result to the screen

    In article <google.com>,
    fr (Loic BERTRAND) wrote:
     

    NSImage has a -lockFocus method, just like NSView. Create an NSImage
    with the appropriate NSImageRep if you need it, -lockFocus on it, and
    draw.
    Michael Guest

  5. #5

    Default Re: Drawing *without* :-) outputting the result to the screen

    Thank you,

    I suspect that my code is not very beautiful, but at least it works
    now:

    NSRect theBgRect = NSMakeRect(0, 0, tX, tY);
    NSBezierPath *theBgPath = [NSBezierPath
    bezierPathWithRect:theBgRect];
    // for background (probably a better way to do it)
    // [theImage setBackgroundColor:bgColor] does not work here (why
    ?)

    [theImage lockFocus];

    [bgColor set];
    [theBgPath fill];

    [diskColor set];
    [thePath fill];

    [theImage unlockFocus];

    NSLog(" Generating PNG representation");
    NSData *theData = [theImage TIFFRepresentation];
    theBitmapRep = [NSBitmapImageRep imageRepWithData:theData];
    [[theBitmapRep representationUsingType:NSPNGFileType
    properties:nil] writeToFile:aFile atomically:YES];
    Loic Guest

  6. #6

    Default Re: Drawing *without* :-) outputting the result to the screen

    Loic BERTRAND wrote:
     

    It appears from your code you are only trying to fill in a rectangle.
    You should use functions such as NSRectFill(), which are faster and
    easier to use, for this purpose.

    -Peter

    Peter Guest

Similar Threads

  1. Drawing in Flex? Drawing and AS for custom compon
    By yoway in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: April 18th, 10:19 PM
  2. Process of drawing an image to the screen? (technical)
    By Pixel_Pixie webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 2
    Last Post: January 16th, 09:01 PM
  3. Explain the process of drawing a png to the screen. (technical)
    By Pixel_Pixie webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 0
    Last Post: January 13th, 09:46 PM
  4. Replies: 3
    Last Post: August 1st, 05:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139