Professional Web Applications Themes

OffScreen and palette - Mac Programming

Hi, first time user of this forum. here my problem: I want to know the exact value of an RGB color of a pixel; first, I read a palette in the resource fork: aPalette = GetNewPalette(noPalette); nbColors = (* aPalette)->pmEntries; for (i = 0; i <= nbColors; i++) theColorsRGB[i] = (* aPalette)->pmInfo[i].ciRGB; then, I open an offScreen port and set the pixels colors: error = NewGWorld(&offScreenGWorld, 0, &imageRect, NULL, NULL, 0); .... SetCPixel(h, v, & theColorsRGB[k]); GetCPixel(h, v, &aColorRGB); if (aColorRGB.red != theColorsRGB[k].red) { Alert("different"); } I test the color and get a message telling me that the color is ...

  1. #1

    Default OffScreen and palette

    Hi, first time user of this forum.

    here my problem: I want to know the exact value of an RGB color of a pixel;

    first, I read a palette in the resource fork:

    aPalette = GetNewPalette(noPalette);
    nbColors = (* aPalette)->pmEntries;
    for (i = 0; i <= nbColors; i++)
    theColorsRGB[i] = (* aPalette)->pmInfo[i].ciRGB;


    then, I open an offScreen port and set the pixels colors:

    error = NewGWorld(&offScreenGWorld, 0, &imageRect, NULL, NULL, 0);

    ....

    SetCPixel(h, v, & theColorsRGB[k]);
    GetCPixel(h, v, &aColorRGB);
    if (aColorRGB.red != theColorsRGB[k].red)
    {
    Alert("different");
    }


    I test the color and get a message telling me that the color is not the
    one I gave to SetCPixel();

    The colors are very similar but not identical.
    I must say that there is no code between SetCPixel() and GetCPixel();

    I have try
    SetPalette((GrafPort *)offScreenGWorld, aPalette, false);
    et
    error = NewGWorld(&offScreenGWorld, 32, &imageRect, NULL, NULL, 0);
    without success.

    Is there somebody having an idea around here?
    thank you
    JJC
    Montreal

    jean-jacques Guest

  2. #2

    Default Re: OffScreen and palette

    In article <com>,
    jean-jacques Chailloux <com> wrote:
     

    Palettes only make sense for 8-bit per pixel and thinner pixMaps.

     

    Here you are making a pixMap the same depth as the CRT. How deep is your
    screen?
     

    Here you are making a pixMap that is 32 bits per pixel: 8-bits of red,
    8-bits of green, 8-bits of blue.

     

    Here you are specifying a pixel with 16-bits of red, 16-bits of green,
    16-bits of blue.
     

    Here you are reading a pixel back from a pixMap that has at most 8-bits
    of red, 8-bits of green, 8-bits of blue. I beleive that the Macintosh OS
    puts the actual values in the high order bits of each component, then
    copies those 8-bits into the low order bits. Mapping 0x00 .. 0xFF to
    0x0000 .. 0xFFFFF.
     


    write:

    if( (aColorRGB.red & 0xFF00) == (theColorsRGB[k].red & 0xFF00)){
    Alert("different");
    }

    and always use 32-bit deep pixmaps.
    David Guest

  3. #3

    Default Re: OffScreen and palette



    David Phillip Oster a écrit: 
    >
    >
    > Palettes only make sense for 8-bit per pixel and thinner pixMaps.
    >
    >[/ref]
    I though Palettes reduce the number of colors, not the number of bits
    per pixels
     
    >
    >
    > Here you are making a pixMap the same depth as the CRT. How deep is your
    > screen?
    >[/ref]
    32 bits (millions colors)
     
    >
    >
    > Here you are making a pixMap that is 32 bits per pixel: 8-bits of red,
    > 8-bits of green, 8-bits of blue.
    >
    >

    >
    >
    > Here you are specifying a pixel with 16-bits of red, 16-bits of green,
    > 16-bits of blue.
    >

    >
    >
    > Here you are reading a pixel back from a pixMap that has at most 8-bits
    > of red, 8-bits of green, 8-bits of blue. I beleive that the Macintosh OS
    > puts the actual values in the high order bits of each component, then
    > copies those 8-bits into the low order bits. Mapping 0x00 .. 0xFF to
    > 0x0000 .. 0xFFFFF.
    >

    >
    >
    >
    > write:
    >
    > if( (aColorRGB.red & 0xFF00) == (theColorsRGB[k].red & 0xFF00)){
    > Alert("different");
    > }
    >[/ref]
    it seems you are right with this test but how to tell QuickDraw to use
    unsigned shorts for the RGBcolors
     
    I will have to read the QD doc. again...
    Thank you for the hint
    JJC
    Montreal

    jean-jacques Guest

  4. #4

    Default Re: OffScreen and palette

    In article <com>,
    jean-jacques Chailloux <com> wrote:
     

    An RGBColor is defined as 3 unsigned shorts.
    David Guest

  5. #5

    Default Re: OffScreen and palette



    David Phillip Oster a écrit: 
    >
    >
    > An RGBColor is defined as 3 unsigned shorts.[/ref]

    Yes, I know but why do I have to read the palette that way?

    lesCouleursRGB[i].red = (*unePalette)->pmInfo[i].ciRGB.red & 0xFF00;

    and test the color this way

    if((laCouleurRGB.red & 0xFF00) != (lesCouleursRGB[k].red & 0xFF00))

    the test shows that
    (laCouleurRGB.red & 0xFF00) equals (lesCouleursRGB[k].red & 0xFF00)
    and
    (laCouleurRGB.red) does not equal (lesCouleursRGB[k].red)

    ?????

    jjc
    Montreal

    jean-jacques Guest

  6. #6

    Default Re: OffScreen and palette

    In article <com>,
    jean-jacques Chailloux <com> wrote:
     
    > >
    > >
    > > An RGBColor is defined as 3 unsigned shorts.[/ref]
    >
    > Yes, I know but why do I have to read the palette that way?
    >
    > lesCouleursRGB[i].red = (*unePalette)->pmInfo[i].ciRGB.red & 0xFF00;
    >
    > and test the color this way
    >
    > if((laCouleurRGB.red & 0xFF00) != (lesCouleursRGB[k].red & 0xFF00))[/ref]

    I explained this already.

    Since the video card only provides 8-bits per color component, when you
    read a pixel back from the video card, and it is placed into a 16-bit
    per component RGBColor, the Mac OS puts the actual 8-bits in the high
    order bits of the component and synthesisizes the low order bits. There
    are really only 256 distinct values that a color component can take on.
    It isn't surprising that when you compare that to an arbitrary 16-bit
    number it doesn't match all the time.
    David Guest

Similar Threads

  1. Game will not maximize - offscreen buffer
    By pgharrcs in forum Macromedia Shockwave
    Replies: 0
    Last Post: February 13th, 07:24 AM
  2. Offscreen Grid -Flex
    By Slistak2002 in forum Macromedia Flex General Discussion
    Replies: 2
    Last Post: September 20th, 05:16 PM
  3. Lost Layers Palette; Reset Palette Layout to Default?
    By Eric_Oliver@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 3
    Last Post: May 21st, 07:51 AM
  4. Can't Open Layers Palette or Symbols Palette
    By Mervin_Aronoff@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 1
    Last Post: May 9th, 10:15 PM
  5. Photoshop dialog boxes are 'offscreen' after going from two monitors to one
    By mike verzella in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 10
    Last Post: September 12th, 06:38 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