What result would I get for the following?

Assume we have Image object, width and height already.
public int[][] getRedArray()
int values[] = new int[imageWidth * imageHeight];
PixelGrabber grabber = new PixelGrabber(imageobj.getSource(), 0, 0, imageWidth, imageHeight, values, 0, imageWidth);
try
if(grabber.grabPixels() != true)
try
throw new AWTException("Grabber returned false: " + grabber.status());
catch (Exception e) {};
catch (InterruptedException e) {};
int r[][] = new int[imageWidth][imageHeight];
int index = 0;
for (int y = 0; y < imageHeight; ++y)
for (int x = 0; x < imageWidth; ++x)
r[x][y] = ((values[index] & 0x00ff0000) >> 16);
index++;
return r;
Could you please please explain how this code works? brief step-by-step explaination would be satisfied.
Please explain explicitly how "r[x][y] = ((values[index] & 0x00ff0000) >> 16);" this works.
Thank you so much!! :)

Consider the following :
In this case a color is stored as 4 bytes. Each byte holds a color component, namely Alpha, Red, Green and Blue. In that order.
Now, 4 bytes = 1 int. The color is stored in an int, so bits 16-23 hold the red component. If you want to isolate that byte you'll need to do two things :
1) Isolate the "red" bits
2) Move them from bits 16-23 to 0-7
So, if we take the color value in bits, where A, R G and B signify a single bit reserved for an alpha, red, green or blue color component respectively :
AAAAAAAARRRRRRRRGGGGGGGGBBBBBBBBStep 1) is isolating the red :
00000000RRRRRRRR0000000000000000You do this by doing a bitwise AND with operand 1 being the color int, and operands 2 being an integer whose 16-23 bits are set :
color & 0x00ff0000Step 2) is moving the red bits to 0-7 :
(color & 0x00ff0000) >> 16
000000000000000000000000RRRRRRRRNow it's a valid integer value ranging from 0-255 and you can use it, as done in your code snippet.

Similar Messages

  • What solutions would be needed for the following scenario

    I have a client who operates two companies.
    One company manufactures a specific piece of equipment.
    The other company rents, sells and services this piece of equipment.  This equipment consists of three major interchangeable components.
    They need to track:
    Customer information u2013 company name, contact person, start date, end date, sold or rental unit, service schedule on the three major components.
    Equipment information u2013 where it is, which components it consists of, service records, forecast of service requirement, data on each specific component.
    Job information u2013 field tickets, work orders, distance traveled for installations and service work, how long  units have been running.
    Revenue information u2013 all pertinent information as well as what was billed and when.
    Inventory information u2013 all pertinent information as well as which parts have been used by manufacturing and which parts have been used to maintain the rental assets or service on sold equipment.
    They also want to automatically contact operators and client about upcoming service dates.
    My expertise is in SAP HR.  Which SAP modules would they need to accomplish this?  Is there another solution they should consider?

    They need to track:
    Customer information u2013 company name, contact person, start date, end date, sold or rental unit, service schedule on the three major components.
    SD Modules
    Equipment information u2013 where it is, which components it consists of, service records, forecast of service requirement, data on each specific component.
    PM Modules
    Job information u2013 field tickets, work orders, distance traveled for installations and service work, how long units have been running.
    PM Modules
    Revenue information u2013 all pertinent information as well as what was billed and when.
    SD Modules
    Inventory information u2013 all pertinent information as well as which parts have been used by manufacturing and which parts have been used to maintain the rental assets or service on sold equipment.
    MM Module
    They also want to automatically contact operators and client about upcoming service dates.
    CS Module

  • Would ARD work for the following situation...?

    Hello, trying to logically map out how to do something and wonder if some of ya could help me...
    Here is the deal.  I'm a narrator and my current studio set-up is one where I have an outer
    control room where my computer with sound software and monitor are located.  When I perform,
    I "roll tape" (i.e., start my audio software app)  and then go into my isolated sound booth to
    read my script printout. 
    I would like to have a monitor inside the booth whereby I can monitor, visually, the
    displayed audio on the outer-room monitor while I record, as well as read scripts off
    the screen rather than having to print them.  I'd also need a keyboard/mouse in the
    soundbooth - which presumably would be a wireless bluetooth arrangement - 
    Am just trying to figure out the most logical way to accomplish this -  Would it make
    sense to use Remote Desktop to serve as the secondary monitor - and would it work
    for what I'm describing - or otherwise, any ideas on a simple straightforward way to
    accomplish what I'm looking to do..?  this is just a project i've put off for years and
    would like to finally get it together.  Some had suggested video mirroring - and the
    issue of bluetooth distance from the outer-room CPU may be a problem - I don't know.
    Others thought i should hardwire usb and video cables into the booth from a separate,
    dedicated computer that shared my Airport/Ethernet network...
    Of course, if all this belongs in a different discussion, feel free to 'tell me where to go; )
    Hope my explanation is clear and Thanks much for any ideas!
    Mike

    For just doing remote control, ARD would be overkill. Mac OS X 10.5 and 10.6 both have screen sharing built in, so if you can put a computer in the recording room, that would be all you'd need. Or you could just extend a monitor, keyboard and mouse into the room (Bluetooth for the keyboard and mouse if close enough, or USB). There are extenders if the distance is too great for normal runs, though the extenders, particularly for video, are a bit spendy.
    If space and noise are the primary concerns, a remote control solution using an iPad, such as Remote Conductor might be an option.
    Regards.

  • Hello friends, what printer do you recommend for the iMac OS X Mt Lion?

    Hello friends, what printer would you recommend for the iMac OS X Mt Lion?

    There are hundreds that will work,  you need to determine what your needs are and then go shopping. For a list of compatible printers and all-in-one's please look over Apple's advice letter:
    http://support.apple.com/kb/HT3669

  • Adobe Flash Player not working. Installen latest version. Get the following: "This website would like to run the following addon: Adobe Flash Player from Adobe System Incorporated." Then asking me to allow it for current or all websites. It doesn´t matter

    Adobe Flash Player not working. Installen latest version. Get the following: "This website would like to run the following addon: Adobe Flash Player from Adobe System Incorporated." Then asking me to allow it for current or all websites. It doesn´t matter how i do this. The pop-up question returns EVERY time. What do i do to solve this issue???

    To give you any useful advice, I'm going to need to know more about your computer and browser:
    https://forums.adobe.com/message/5249945#5249945

  • What new setup would you get for editing video in iMovie?

    Hey gang. I'm upgrading all the electronics in my home and would love some buying and configuring advice. This question could go in the desktop discussion group as well, but the main thing that will tax the next system is family video editing and (temporary) storage. What desktop would you get? iMac or maybe Mac Mini? What camcorder? Canon Vixia ( http://www.bhphotovideo.com/c/product/838768-REG/Canon_M50_HF_M50.html )? I want movies to load quickly and easily, so was thinking of one with SD card media.  Time Capsule? (One advisor said to go with another router). And if you were going to get a new TV, what would you get? Flat panel or projector? Yeah, I know: my credit card is gonna be lovin' me.  Been saving up, though, and just built all new furniture for my home office, so I can't wait to load it up with nice new gear. Thanks for any advice!

    Karsten Schlüter wrote:
    • TimeCapsule is no router, but a backup machine; add another drive to backup backup
    Sorry to correct that Karsten - you are always right normally
    From the Apple Store ( http://store.apple.com/us/product/MD033LL/A/time-capsule-3tb?fnode=4d )
    Easy wireless networking.
    Connect your DSL or cable modem to Time Capsule, then quickly set it up with the easy-to-use AirPort Utility, which is available as download for both Mac OS X and Windows. In minutes, you and up to 50 others can use your Mac computers or PCs to surf the web, stream video, share photos and more — without wires.3
    I think that earlier versions fit your description, but the latest does have wireless networking. It works like the Airport Extreme base station.
    John
    Message was edited by: John Cogdell

  • What can I do for the following situation: I think my insert slot for the headphones does not work; when I put in any cable that should and can go in all I hear is low frequent static sounds.

    What can I do for the following situation: I think my insert slot for the headphones does not work; when I put in any cable that should and can go in all I hear is low frequent static sounds.

    You might try talking to the Apple store manager and see if you don't get more help...you might also contact Apple.com/support and see if they can give you a contact with the Apple Italy offices.
    Sounds like you have two levels of failure, the first shop that did the repair and broke a wire, and the second that has disabled something else and isn't helping.
    Apple officially refurbished equipment is usually good quality.  Surprising this has happened but you need to press on with complaints and try for resolution.

  • What r all the tables  used for the following report

    hai
    what r all the tables  used for the following report
    report:
    <b>
    •     Report that displays all the late shipments in a particular period of time</b>
    send important fields for this tables also
    thanks in advance.

    Hi,
       Imp table are vttk,vttp,vtts.
    Regards
    Amole

  • I'm currently running 10.6.8 and would like to upgrade to mountain lion but all i keep getting is the following: We could not complete your purchase. OS X Mountain Lion is not compatible with this computer. help

    I'm currently running 10.6.8 and would like to upgrade to mountain lion but all i keep getting is the following: We could not complete your purchase. OS X Mountain Lion is not compatible with this computer. help

    ERA AND MCM wrote:
    We could not complete your purchase. OS X Mountain Lion is not compatible with this computer.
    it means exactly that, you mac is not compatible to run ML. http://support.apple.com/kb/SP654

  • Would like to purchase PSE 12 to process Camera Raw files for the following cameras: Nikon D800, Nikon DF, Canon G9 and Pentax K-3 does the Raw Converter that comes with  PSE 12 when purchased recognize  the cameras listed in the question or do I need to

    Would like to purchase PSE 12 to process Camera Raw files for the following cameras: Nikon D800, Nikon DF, Canon G9 and Pentax K-3 does the Raw Converter that comes with  PSE 12 when purchased recognize  the cameras listed in the question or do I need to download  the camera Raw Version 8.3 ?

    While the G9 RAW files can be read by Adobe Camera RAW and Lightroom, these file are unsupported at this time. Here is a link to Adobe's latest list of cameras that are supported and this list came out yesterday http://www.adobe.com/products/photoshop/cameraraw.html
    I have not done a comparison between Lightroom and Canon's software but others have and say that Canon's software is clearly better. I am sure when Adobe updates their software again to include the G9 it will be a very good RAW converter as it is will most other cameras.

  • What camera raw default settings would you use for the Canon 5D Mark 3. I have PS CS6.  Thank you.

    What camera raw default settings would you use for the Canon 5D Mark 3. I have PS CS6.  Thank you.

    Really, this is a question you should be asking yourself...
    What do you shoot? Makes a difference...
    Typical ISO that you shoot? Makes a difference...
    Shooting for clients or yourself? Makes a difference...
    Look, there is no magic bullet...the ACR/LR "Default" should only be changed for those adjustments you make 70-90% of the time and sould not be confused with image by image adjustments...
    So, as asked, your question can not really be answered other than to say, use a default that suits you.

  • Hello  J have problem in the demarage d iphoto the dialogue displays and asks me for the following text?  138 photos not having been imported were found in the iPhoto library(bookcase).  Would you care for import them? Yes or no you already have meet this

    onjour
    j ai des probleme au demarage d iphoto le dialogue s affiche et  me demande le  texte suivant ?
    138 photos n’ayant pas été importées ont été trouvées dans la bibliothèque iPhoto.
    Souhaitez-vous les importer ? oui  ou non avez vous deja rencontrer ce proble  si oui pouvez vous m aider
    Merci
    Hello
    J have problem in the demarage d iphoto the dialogue displays and asks me for the following text?
    138 photos not having been imported were found in the iPhoto library(bookcase).
    Would you care for import them? Yes or no you already have meet this prowheat if yes can you m help
    Thank you

    Open your iPhoto Library package with the Finder as shown in this screenshot
    and look in the folder named Auto Import.  Move any files in that folder to a folder on the Desktop and close the package. Do not make any other changes.  Launch iPhoto (the message should be gone) and drag the folder on the Dersktop into the open iPhoto window to import them.
    OT

  • What is the difference between mouton lion, lion, snow leopard?  I have an iPad, iPhone and iMac but I have no idea what you would use these for?

    What is the difference between mouton lion, lion, snow leopard?  I have an iPad, iPhone and iMac but I have no idea what you would use these for?

    Probably. Back up your data and check your applications for compatibility before installing it.
    (111162)

  • Caznnot upgrade my iTunes to version 10.4.1---get message---The following install step failed: runupgrade script for Apple mobile device support.--Contact softwae=re manufacturer for assistance

    Cannot upgrade my iTunes to version 10.4.1---get message---The following install step failed: runupgrade script for Apple mobile device support.--Contact softwae=re manufacturer for assistance.
    Can someone help me?
    Thank you.
    Gerald

    me too did you get any help?

  • Cannot upgrade my iTunes to version 10.4.1---get message---The following install step failed: runupgrade script for Apple mobile device support.--Contact softwae=re manufacturer for assistance.   Can someone help me? Thank you.   Gerald

    Cannot upgrade my iTunes to version 10.4.1---get message---The following install step failed: runupgrade script for Apple mobile device support.--Contact softwae=re manufacturer for assistance.
    Can someone help me?
    Thank you.
    Gerald

    me too did you get any help?

Maybe you are looking for

  • Error while deploying EAR file on OC4J 10.1.3.3

    Hi all, I am facing following error on OC4J while deploying EAR file Error occurred during initialization of VM Could not reserve enough space for object heap 07/12/31 17:47:21 oracle.oc4j.admin.internal.DeployerException: Error compiling :C:\exp\war

  • Generate report of IO/datafile performance?

    Hello, I am working on some performance issues that we believe could be related to the IO subsystem. I am trying to find a way to get a baseline of the true IO performance of the database, looking only at datafile IO. In AWR reports, you can see vari

  • Want to perform live with Garageband... How do I hook up to a PA system?

    Looking to use My iMac G5 live on stage to run backing tracks while I play keyboards live. What is the best way to hook up the computer to the PA system? Can I do it direct or should I use my M-audio MobilePre USB? Please Advise... thanks

  • Questionable website and security concern

    I was searching google images and clicked on an image which took me to: *(do not click if you don't know what your doing please!!)* < Edited by Host > More specifically: < Edited by Host > Is this of any concern to me? It seemed like some possible cr

  • Question abotu String.format() functionality

    Hello all, I am curious as to whether this functionality exists in the String.format method, or if there is any other class in the current version of Java that would allow for this. I want to construct a format string, where if one of the args contai