Professional Web Applications Themes

[QT] Using Bicubic Interpolation via Raw/None Codec - Mac Programming

I'm having some difficulty using QuickTime 6.x's new bicubic interpolation feature. What I'm trying to do is use the Raw/None codec to interpolate a GWorld into a smaller image. I'm targeting both Windows and Macs with the code base... I've already posted a Radar bug (#3461464) about this issue, but I'm not convinced I'm doing things correctly in the first place. What follows is a edited code excerpt that shows the program flow that I've currently implemented. With STORE_LIKE_FILE undefined, the code shows the undesired behavior. Defining it implements a workaround where the image is converted to an in-memory "file" ...

  1. #1

    Default [QT] Using Bicubic Interpolation via Raw/None Codec

    I'm having some difficulty using QuickTime 6.x's new bicubic
    interpolation feature. What I'm trying to do is use the
    Raw/None codec to interpolate a GWorld into a smaller image.
    I'm targeting both Windows and Macs with the code base...

    I've already posted a Radar bug (#3461464) about this issue, but I'm
    not convinced I'm doing things correctly in the first place. What
    follows is a edited code excerpt that shows the program flow that
    I've currently implemented. With STORE_LIKE_FILE undefined,
    the code shows the undesired behavior. Defining it implements
    a workaround where the image is converted to an in-memory "file"
    via export/import components.

    The full version of the code can be found here; it's a modified
    version of one of Apple's QuickTime example projects...

    <http://www.ameritech.net/users/wormwood/DecompScalingWorkaround.sit>

    ....the code in this message has had its error checking and context
    removed for brevity. I may have made some errors in editing; the
    code in the above CodeWarrior project should be taken as the
    definitive case.

    ** BEGIN CODE SNIPPET **

    /* #define STORE_LIKE_FILE */

    GWorldPtr srcGWorld;
    PixMapHandle srcPixMap;
    Rect pictBounds;
    Rect finalBounds;
    ImageDescriptionHandle desc;
    CGrafPtr savedPort;
    GDHandle savedDevice;
    #ifdef STORE_LIKE_FILE
    ComponentInstance theProcessor;
    Handle imageHandle;
    #else
    MatrixRecord theTransform;
    #endif

    /* Determine image sizes here, pictBounds & finalBounds */

    NewGWorld(&srcGWorld, 32, &pictBounds, nil, nil, 0);
    srcPixMap = GetGWorldPixMap(srcGWorld);
    LockPixels(srcPixMap);

    GetGWorld(&savedPort, &savedDevice); /* Belongs to gWindow, BTW */
    SetGWorld(srcGWorld, nil);

    /* Do drawing into srcGWorld/srcPixMap here... */

    SetGWorld(savedPort, savedDevice);

    MakeImageDescriptionForPixMap(srcPixMap, &desc);

    #ifdef STORE_LIKE_FILE

    OpenADefaultComponent(GraphicporterComponentTyp e,
    kQTFileTypeJPEG, &theProcessor);
    GraphicportSetInputGWorld(theProcessor, srcGWorld);
    GraphicportSetCompressionQuality(theProcessor,
    codecHighQuality);
    imageHandle = NewHandle(1);
    GraphicportSetOutputHandle(theProcessor, imageHandle);
    GraphicportDoExport(theProcessor, NULL);

    CloseComponent(theProcessor);

    DisposeGWorld(srcGWorld);

    OpenADefaultComponent(GraphicsImporterComponentTyp e,
    kQTFileTypeJPEG, &theProcessor);
    GraphicsImportSetDataHandle(theProcessor, imageHandle);
    GraphicsImportSetGWorld(theProcessor, savedPort,
    savedDevice);

    #endif

    #ifdef STORE_LIKE_FILE

    GraphicsImportSetBoundsRect(theProcessor, &finalBounds);
    GraphicsImportSetQuality(theProcessor, codecLosslessQuality);
    GraphicsImportDraw(theProcessor);

    #else

    RectMatrix(&theTransform, &pictBounds, &finalBounds);

    FDecompressImage(GetPixBaseAddr(srcPixMap), desc,
    GetPortPixMap(GetWindowPort(gWindow)),
    nil, &theTransform, srcCopy + ditherCopy, nil, nil, nil,
    codecLosslessQuality, anyCodec, nil, nil, nil);

    #endif

    ** END CODE SNIPPET **

    Am I on the right track, or is there some easier or different
    way to approach this problem while using only the QuickTime API?
    I'm posting this message to both the comp.sys.mac.programmer.*
    newsgroups and the QuickTime API mailing list.

    Des
    Des Guest

  2. #2

    Default Re: [QT] Using Bicubic Interpolation via Raw/None Codec

    net (Des Courtney) wrote in message news:<google.com>... 

    I thought bicubic scaling was less-than-good when scaling down???

     
     


    Not sure...but don't you want high quality here? Same with the
    FDecompress call?

     

    There has been sample code posted on the QuickTime API mailing list
    that demonstrates this. You could find it in the archives.

    Here's a few quick links I found searching the QT API archives for
    bicubic scaling turkowski (I'm sure he posted info about this)

    http://lists.apple.com/archives/quicktime-api/2002/Aug/16/nonecodecenhancementsinq.003.txt

    http://lists.apple.com/archives/quicktime-api/2002/Aug/16/nonecodecenhancementsinq.txt

    Looks like it may not work with FDecompressImage

    Bryan
    Bryan Guest

  3. #3

    Default Re: [QT] Using Bicubic Interpolation via Raw/None Codec

    In article <google.com>,
    com (Bryan Pietrzak) wrote:
     
    >
    > I thought bicubic scaling was less-than-good when scaling down???[/ref]

    Yes, however QuickTime will select the appropriate scaling algorithm
    based upon the matrix being used.
     

    >
    >
    > Not sure...but don't you want high quality here? Same with the
    > FDecompress call?[/ref]

    Nope. codecLosslessQuality is what one should specify in order to
    obtain the highest quality scaling from the Raw codec. Actually, the
    cut-point is codecMaxQuality, but the "lossless" constant is greater
    than codecHighQuality.

    More description of these changes can be found in the "What's new in
    QuickTime 6" doentation, specifically the section on the "None" codec.
    Tom Guest

  4. #4

    Default Re: [QT] Using Bicubic Interpolation via Raw/None Codec

    > Nope. codecLosslessQuality is what one should specify in order to 
    codec.

    And it says use codecMaxQuality.

    --
    Norman Black
    Stony Brook Software

    "Tom Dowdy" <com> wrote in message
    news:apple.com... 
    > >
    > > I thought bicubic scaling was less-than-good when scaling down???[/ref]
    >
    > Yes, however QuickTime will select the appropriate scaling algorithm
    > based upon the matrix being used.

    > > 
    > >
    > >
    > > Not sure...but don't you want high quality here? Same with the
    > > FDecompress call?[/ref]
    >
    > Nope. codecLosslessQuality is what one should specify in order to
    > obtain the highest quality scaling from the Raw codec. Actually, the
    > cut-point is codecMaxQuality, but the "lossless" constant is greater
    > than codecHighQuality.
    >
    > More description of these changes can be found in the "What's new in
    > QuickTime 6" doentation, specifically the section on the "None"[/ref]
    codec.

    Norman Guest

  5. #5

    Default Re: [QT] Using Bicubic Interpolation via Raw/None Codec

    In Article google.com, Des Courtney
    wrote:
     

    Works for me. Though, try using codecMaxQuality.

    --
    Mike Kluev

    PS. Remove "-DELETE-." part of my e-mail address to reply.

    Mike Guest

  6. #6

    Default Re: [QT] Using Bicubic Interpolation via Raw/None Codec

    > > FDecompressImage(GetPixBaseAddr(srcPixMap), desc, 
    >
    > Works for me. Though, try using codecMaxQuality.
    >
    > --
    > Mike Kluev[/ref]

    I have found the FDecompressImage does not use anything but point
    sampling. It does a better job at sampling than CopyBits but still not
    as good a job as bilinear and/or bicubic. I found the sequence

    DecompressSequenceBeginS
    DecompressSequenceFrameS
    CDSequenceEnd

    Does use the quality interpolation modes.

    --
    Norman Black
    Stony Brook Software

    "Mike Kluev" <-DELETE-.org> wrote in message
    news:BBE52F7E.16833%-DELETE-.org... 
    Courtney 
    >
    > Works for me. Though, try using codecMaxQuality.
    >
    > --
    > Mike Kluev
    >
    > PS. Remove "-DELETE-." part of my e-mail address to reply.
    >[/ref]

    Norman Guest

Similar Threads

  1. PSCS interpolation options
    By Doug_Katz@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 13
    Last Post: February 19th, 12:53 AM
  2. variable interpolation syntax (SERVER_SIGNATURE)
    By Peter Horst in forum PHP Development
    Replies: 1
    Last Post: November 4th, 12:24 AM
  3. Imaging Lingo: Bicubic Sampling
    By protocol_droid webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 2
    Last Post: September 1st, 10:35 AM
  4. interpolation
    By Ken in forum Photography
    Replies: 0
    Last Post: July 28th, 09:51 AM
  5. Cursor smoothness/interpolation
    By neurobound in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 0
    Last Post: June 29th, 03:18 AM

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