Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / August 2007



Tip: Looking for answers? Try searching our database.

Using QD PicHandle at iMac...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fonarix - 29 Aug 2007 13:34 GMT
Greetings!
I've got a problem on porting old App to iMac.
Currently, i can't get code for extracting RGB data from PicHandle.
For Skinning my application (I using background picture and foreground
picture, in foreground not used pixels - same as [0,0] of pict, all
removed by background ) is there some code for resolving this issue?
At PPC all works fine. I am afraid, that porting to Quartz 2D is very
difficult.

Thanks!
David Phillip Oster - 29 Aug 2007 15:19 GMT
> Greetings!
> I've got a problem on porting old App to iMac.
[quoted text clipped - 6 lines]
>
> Thanks!

You say: "At PPC all works fine".

QD Pichandles can also be made to work on Intel Macintoshes. See for
http://developer.apple.com/documentation/MacOSX/Conceptual/universal_bina
ry/universal_binary_tips/chapter_5_section_30.html more details. It is
part of this larger document:
http://developer.apple.com/documentation/MacOSX/Conceptual/universal_bina
ry/

Which in turn is part of this: http://developer.apple.com/transition/

A QD Pichandle can be transformed into a file in PICT format (write 512
bytes of zeros, then the Pichandle data.) From there, you can use a
graphics editor to read in the file, and write it out as a .PNG file.  
.PNGs can have alpha channels, and Cocoa knows how to load and draw them.
Fonarix - 29 Aug 2007 16:05 GMT
> In article <1188390889.757895.131...@19g2000hsx.googlegroups.com>,
>
[quoted text clipped - 22 lines]
> graphics editor to read in the file, and write it out as a .PNG file.
> .PNGs can have alpha channels, and Cocoa knows how to load and draw them.

I've found that QDGetPictureBounds works sometime with bugs (values
scaled on 255 (8-bit) )
This code can resolve this problem:

        hBitmap    = (long)GetPicture(ABS(PictId));
        Rect rframe;
        QDGetPictureBounds((PicHandle)hBitmap, &rframe );
        rframe.right = MIN((**(PicHandle)hBitmap).picFrame.right,
rframe.right);
        rframe.bottom = MIN((**(PicHandle)hBitmap).picFrame.bottom,
rframe.bottom);
        (**(PicHandle)hBitmap).picFrame = rframe;

And... How can I get data from PicHandle on iMac? Currently I'm using
this code:

    PixMapHandle    px;
    GWorldPtr     pGWorld = PictGWorld(*pictHandle,&rect,&w,&h);

    px = GetGWorldPixMap(pGWorld); //

    UInt8    *baseAddress = (UInt8 *)GetPixBaseAddr(px);    //
(**px).baseAddr;//
    long    rowBytes2 = (*px)->rowBytes;

    rowBytes2 = GetPixRowBytes(px);

    LockPixels(px);

    ct = 0;
    for (long j=0; j < h; j++)
    for (long i=0; i < w; i++){

//        GetCPixel(i, j, &cPix); // Doesn't work on iMac
//        R[ct] = (SHORT8)((DFLOAT) cPix.red  /(DFLOAT)0xFFFF*255.0);
//        G[ct] = (SHORT8)((DFLOAT) cPix.green/(DFLOAT)0xFFFF*255.0);
//        B[ct] = (SHORT8)((DFLOAT) cPix.blue /(DFLOAT)0xFFFF*255.0);
        UInt8 *pixelAddr = baseAddress + (j)*rowBytes2 + 4*(i);

// And this alternative method, doesn't work too on iMac
        R[ct] = (*(SHORT8*)&pixelAddr[1]) ;
        G[ct] = (*(SHORT8*)&pixelAddr[2]) ;
        B[ct] = (*(SHORT8*)&pixelAddr[3]) ;
        ct++;
    }
    UnlockPixels(px);

At iMac I have just rectangle filled with some color...
David Phillip Oster - 29 Aug 2007 16:45 GMT
> I've found that QDGetPictureBounds works sometime with bugs (values
> scaled on 255 (8-bit) )
[quoted text clipped - 8 lines]
> rframe.bottom);
>         (**(PicHandle)hBitmap).picFrame = rframe;

I find it hard to believe that QDGetPictureBounds() only works some of
the time. I'd take a good hard look at your program to see if something
else wasn't pre-swapping some of your resources.

> And... How can I get data from PicHandle on iMac? Currently I'm using
> this code:
> ...

Why are you trying to read the result of drawing the PICT one pixel at a
time? Since you are eventually going to be drawing, see:

http://developer.apple.com/documentation/Carbon/Conceptual/QuickDrawToQua
rtz2D/

and if you really do need the numeric values of the pixel, the following
reference should help:

http://developer.apple.com/documentation/MacOSX/Conceptual/universal_bina
ry/universal_binary_tips/chapter_5_section_27.html

See also:
http://developer.apple.com/documentation/MacOSX/Conceptual/universal_bina
ry/universal_binary_tips/chapter_5_section_29.html
Fonarix - 31 Aug 2007 09:27 GMT
> In article <1188399902.647946.97...@50g2000hsm.googlegroups.com>,
>
[quoted text clipped - 10 lines]
> > rframe.bottom);
> >            (**(PicHandle)hBitmap).picFrame = rframe;

QDGetPictureBounds, yes - one of the problem - in returned pict frame
some values scalled at 256.
Pre-swapping? I have to swap some how resources? Even they are
compiled at iMac machine???

> I find it hard to believe that QDGetPictureBounds() only works some of
> the time. I'd take a good hard look at your program to see if something
[quoted text clipped - 3 lines]
> > this code:
> > ...

For this skining model, I have to read foreground picture, get pixel
at [0,0] coord, and replace this values in foreground picture with
background picture...

> Why are you trying to read the result of drawing the PICT one pixel at a
> time? Since you are eventually going to be drawing, see:
[quoted text clipped - 10 lines]
> See also:http://developer.apple.com/documentation/MacOSX/Conceptual/universal_...
> ry/universal_binary_tips/chapter_5_section_29.html

Thanks for your reply!!!
Fonarix - 29 Aug 2007 16:06 GMT
> In article <1188390889.757895.131...@19g2000hsx.googlegroups.com>,
>
[quoted text clipped - 34 lines]
> graphics editor to read in the file, and write it out as a .PNG file.
> .PNGs can have alpha channels, and Cocoa knows how to load and draw them.

I've found that QDGetPictureBounds works sometime with bugs (values
scaled on 255 (8-bit) )
This code can resolve this problem:

        hBitmap    = (long)GetPicture(ABS(PictId));
        Rect rframe;
        QDGetPictureBounds((PicHandle)hBitmap, &rframe );
        rframe.right = MIN((**(PicHandle)hBitmap).picFrame.right,
rframe.right);
        rframe.bottom = MIN((**(PicHandle)hBitmap).picFrame.bottom,
rframe.bottom);
        (**(PicHandle)hBitmap).picFrame = rframe;

And... How can I get data from PicHandle on iMac? Currently I'm using
this code:

    PixMapHandle    px;
    GWorldPtr     pGWorld = PictGWorld(*pictHandle,&rect,&w,&h);

    px = GetGWorldPixMap(pGWorld); //

    UInt8    *baseAddress = (UInt8 *)GetPixBaseAddr(px);    //
(**px).baseAddr;//
    long    rowBytes2 = (*px)->rowBytes;

    rowBytes2 = GetPixRowBytes(px);

    LockPixels(px);

    ct = 0;
    for (long j=0; j < h; j++)
    for (long i=0; i < w; i++){

//        GetCPixel(i, j, &cPix); // Doesn't work on iMac
//        R[ct] = (SHORT8)((DFLOAT) cPix.red  /(DFLOAT)0xFFFF*255.0);
//        G[ct] = (SHORT8)((DFLOAT) cPix.green/(DFLOAT)0xFFFF*255.0);
//        B[ct] = (SHORT8)((DFLOAT) cPix.blue /(DFLOAT)0xFFFF*255.0);
        UInt8 *pixelAddr = baseAddress + (j)*rowBytes2 + 4*(i);

// And this alternative method, doesn't work too on iMac
        R[ct] = (*(SHORT8*)&pixelAddr[1]) ;
        G[ct] = (*(SHORT8*)&pixelAddr[2]) ;
        B[ct] = (*(SHORT8*)&pixelAddr[3]) ;
        ct++;
    }
    UnlockPixels(px);

At iMac I have just rectangle filled with some color...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.