Professional Web Applications Themes

Create PICT ressource from JPEG image - Mac Programming

I a newbie in MACOS X programing. I want to open a new dialog containing PICT ressoure (in .r file as header) in a Quicktime component (carbon native) under 10.2/10.3. Due to the fact , this is not an APP application, I can't use NIB files. (or explain me how to associate a nib file to a Quicktime component...) So the best isn't to open a new window using CreateNewWindow and add a image ressource using PICT ressource file (using GetPicture). Thank you....

  1. #1

    Default Create PICT ressource from JPEG image

    I a newbie in MACOS X programing.
    I want to open a new dialog containing PICT ressoure (in .r file as
    header) in a Quicktime component (carbon native) under 10.2/10.3.

    Due to the fact , this is not an APP application, I can't use NIB
    files.
    (or explain me how to associate a nib file to a Quicktime
    component...)

    So the best isn't to open a new window using CreateNewWindow and add a
    image
    ressource using PICT ressource file (using GetPicture).


    Thank you.
    fafa Guest

  2. #2

    Default Re: Create PICT ressource from JPEG image

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

    You can put a JPEG file into a resource using rez:

    ------------
    read 'JPEG' (128) "myart.jpg";

    ------------

    #include <ImageCompression.h>

    In your program, you can read that resource into memory with:

    Handle jh = GetResource('JPEG' 128);

    Handle dataRefH = NewHandle(sizeof Handle);
    GraphicsImportComponent gi;

    **(Handle **) dataRefH = jh;

    GetGraphicsImporterForDataRef(dataRefH, 'hand', &gi);

    then, in your update event handler, you can draw it with:

    CGrafPtr port;
    GDevice dev;

    GetGWorld(&port, &dev);
    GraphicsImportSetGWorld(gi, port, dev);
    GraphicsImportDraw(gi);



    or, you can call

    PicHandle ph;
    GraphicsImportGetAsPicture(gi, &ph);

    WriteResource((Handle) ph, 'PICT', 128, "\p");

    to convert the JPEG image to a PICT resource in a resource file which
    you can draw with DrawPicture().
    David Guest

  3. #3

    Default Re: Create PICT ressource from JPEG image

    David Phillip Oster <org> wrote in message 

    I must create a .r file containing that ?

    I'd try to draw it directly in my windows but it doesn't seem to
    works:

    ...

    result = CreateNewWindow(kDoentWindowClass, windowAttr,
    &bounds, m_theWindow );
    m_g = GetWindowPort( m_theWindow );

    jh = GetResource('JPEG', 128);
    dataRefH= NewHandle(sizeof (Handle));

    **(Handle **) dataRefH = jh;
    GetGraphicsImporterForDataRef(dataRefH, 'hand', &gi);
    GetGWorld(&port,&dev);
    GraphicsImportSetGWorld(gi,port, dev);
    GraphicsImportDraw(gi);
    ShowWindow(m_theWindow);

    I don't understand why it not working. It's so tricky !
    fafa Guest

  4. #4

    Default Re: Create PICT ressource from JPEG image

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

    Most Toolbox functions return error codes. Error codes are there for
    spotting problems.
     

    Compared to?

    BTW, you are probably drawing out of sequence. Traditionally, MacOS
    Windows need to respond to update events and draw there. Otherwise the
    content is unlikely to show up.

    Regards,
    Tom_E

    --
    This address is valid in its unmodified form but expires soon.

    Thomas Guest

  5. #5

    Default Re: Create PICT ressource from JPEG image

    In article <google.com>,
    fr (fafa) wrote:
     
    >
    > I must create a .r file containing that ?[/ref]

    Yes. How else are you getting a JPEG file into a resource?
    David Guest

  6. #6

    Default Re: Create PICT ressource from JPEG image

    Thomas Engelmeier <com> wrote in message news:<de>... 
    >
    > Most Toolbox functions return error codes. Error codes are there for
    > spotting problems.
    > [/ref]

    to X-Windows ! :-)
     

    And how to send such event ? I only what a jpeg displayed in a
    window, not a full GUI !
    fafa Guest

  7. #7

    Default Re: Create PICT ressource from JPEG image

    In article <google.com>,
    fr (fafa) wrote:
     
    > >
    > > Most Toolbox functions return error codes. Error codes are there for
    > > spotting problems.
    > > [/ref]
    >
    > to X-Windows ! :-)
    > [/ref]

    That is a different concept. XWindows has buffers (with usually
    extremely limited bit depth and a more than ugly palette) on the server
    to minimize data transfer, MacOS traditionally had buffering for the
    source data to minimize full display depth buffer sizes.
    Imagine 100 staggered full screen windows - each one takes lets say
    1200x800x4 = 3 840 000 bytes buffer space per window or a total of
    384.000.000 Bytes or 366 MB. It was possible on MacOS also before those
    sizes could be handled by VM and / or real RAM.
     

    Bad luck ;-). You might want to peek at developer.apple.com at the
    sample code section, either in the Quicktime area or the Cocoa area.
    Both have a load of simple GUI apps doing what you want to - and more..

    regards,
    Tom_E

    --
    This address is valid in its unmodified form but expires soon.

    Thomas Guest

  8. #8

    Default Re: Create PICT ressource from JPEG image

    David Phillip Oster <org> wrote in message news:<sf.sbcglobal.net>... 
    > >
    > > I must create a .r file containing that ?[/ref]
    >
    > Yes. How else are you getting a JPEG file into a resource?[/ref]

    My problem is: GetRessource return NULL and RessError return noErr..

    This is why not image is displayed and I don't understand ...

    Maybe is due to the fact I call it from a Quicktime component and not a app.

    Any idea will be apreciated.
    fafa Guest

  9. #9

    Default Re: Create PICT ressource from JPEG image

    In article <google.com>,
    fr (fafa) wrote:
     
    > >
    > > Yes. How else are you getting a JPEG file into a resource?[/ref]
    >
    > My problem is: GetRessource return NULL and RessError return noErr..[/ref]

    GetResource() can return NULL without causing ResError() to return
    something other than noErr. This behavior is doented on Apple's web
    site.

    Is the resource actually in the file that you think it is in? (You can
    check with ResEdit or Resorcerer.)

    At the time you call GetResource(), is the appropriate resource file
    open? (With FSpOpenResFile()). Particularly with plug-ins, the host
    application can open a file, read the code out of it, close the file,
    then call the code, so the plug-in's resource file isn't necessarily in
    the resource chain at the time the plug-in's code is run.
    David Guest

  10. #10

    Default Re: Create PICT ressource from JPEG image

    David Phillip Oster <org> wrote in message news:<sf.sbcglobal.net>... 
    > >
    > > My problem is: GetRessource return NULL and RessError return noErr..[/ref]
    >
    > GetResource() can return NULL without causing ResError() to return
    > something other than noErr. This behavior is doented on Apple's web
    > site.[/ref]

    Yeah I read it.
     

    According to a TN found on apple.com QT component ressource management
    loose path of other resources.
    http://developer.apple.com/technotes/qt/pdf/qt_02.pdf

    So, I don't see how to retreive my jpeg resource inside the
    component.
    Maybe using NIB file, if I found how to do that .

    Thank you for your answers, I sorry , I am a kook in MACOSX
    programming. :-)
    fafa Guest

  11. #11

    Default Re: Create PICT ressource from JPEG image

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

    In the past, I've UUencoded resource data, compiled the UUencoded data
    into my program as a long string (null-terminated const char *), then at
    run time, de-UUencoded it into a handle when the time comes.
    David Guest

  12. #12

    Default Re: Create PICT ressource from JPEG image

    David Phillip Oster wrote: 

    why? i've occasionally embedded graphics in a program, but if you're
    going to do that, you might as well go with the raw bytes, something
    like:

    const unsigned char icon[] =
    {
    0xff,0xff,0xff,0x00,0x7b,0x00,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    // lines snipped
    };

    there's no decoding needed at runtime, and your executable will be
    smaller.
    Jhnny Guest

  13. #13

    Default Re: Create PICT ressource from JPEG image

    In article <nashville.comcast.net>,
    Jhnny Fvrt (it means "halo, then resonate") <com>
    wrote:
     
    >
    > why? i've occasionally embedded graphics in a program, but if you're
    > going to do that, you might as well go with the raw bytes, something
    > like:
    >
    > const unsigned char icon[] =
    > {
    > 0xff,0xff,0xff,0x00,0x7b,0x00,0xff,0xff,
    > 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    > // lines snipped
    > };
    >
    > there's no decoding needed at runtime, and your executable will be
    > smaller.[/ref]

    Quite right. And you can use

    sizeof icon

    to find out how many bytes are in it. Actually, I am oversimplifying and
    misremembering: I never have trouble finding my resource files at run
    time, even in a plug-in, and really I was using HQX for its run-length
    encoding to expand out a new, empty database from a much smaller
    compressed file in a resource. These days I would use a zipLib, but this
    was long ago.
    David Guest

Similar Threads

  1. How to create a vector image from a jpeg in Illustrator CS
    By Jason_Richter@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 19
    Last Post: March 2nd, 08:14 PM
  2. Create PDF and maintain JPEG Resolution
    By barrettaaron@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 6
    Last Post: July 19th, 12:27 PM
  3. How do I create a PICT resource?
    By Andrew Fowler in forum Mac Programming
    Replies: 5
    Last Post: July 31st, 03:00 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