Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to get RGB values?



Just get the colors from the Gworld. U can then use the QTColor object to
get the 'getRed()' etc from each pixel.. Its not fast mind.. But it works
ok.

> Or maybe make a BufferedImage in Java2+, and use a
> QTImageProducer to draw your QT graphics into the
> BufferedImage, then use any standard Java2 techniques to get
> the data (e.g. when instantiating the BufferedImage tell it
> to wrap some int array of yours etc.)
>
>>
>>> The code went on to do it's thing and I get the idea of
> what happened.
>>> However, it seems that once you get the array of pixels,
> you should be
>>> able to do a variety of things. I looked in
> java.awt.image.* and
>>> found ColorModel, which describes getBlue(), getRed(),
> getGreen(),
>>> which seem useful, but ColorModel is declared abstract
> and in typical
>>> fashion when you need something simple, there look to be
> about 10
>>> subclasses and sub-subclasses.
>>>
>>> I didn't see anything comparable in the QTJ API docs but
> I have to
>>> believe that I just missed it. Also, looked on the ADC
> site for info
>>> but that didn't turn up much. Any help would be
> appreciated. Thanks.
>>
>>
>> the PixMap can tell you (a) how big each pixel is
> (getPixelSize) and
>> what format the pixel data is (getPixelFormat).
>>
>> you can save yourself time by allocating the original
> GWorld (aka
>> QDGraphics) yourself, and then you already know the pixel
> format. Make
>> sure you allocate the GWorld _offscreen_ and that way you
> can be sure
>> what you (dont) see is what you get - onscreen display has
> tricks in as
>> much as some kinds of video will display straight to the
> hardware.
>>
>> (I'd look up a pixel format docs for you, you'll have to
> do it yourself
>> - Apple's gone of line for some reason)
>>
>> anyway, for example for an ARGB32 pixel format, you do
>>
>> int pixel = raw.getInt(0); // get pixel from raw image,
> make sure you
>> use rowbytes
>>
>> int a = (pixel >>> 24) & 0xFF;
>> int r = (pixel >>> 16) & 0xFF;
>> int g = (pixel >>> 8) & 0xFF;
>> int b = (pixel >>> 0) & 0xFF; // optimize away ...
>>
>> this arrangement changes for each different kind of pixel
> format, and
>> this is what the AWT image stuff tries to abstract away...
> but like I
>> said - allocate your own *known* pixel format and you can
> get away with
>> it.
_______________________________________________
quicktime-java mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/quicktime-java
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Best way to get RGB values? (From: "George Birbilis" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.