Check pixel colour

In a game, I want to check if a ball is 'in or out' by determining the pixel colour it has landed on - in this case the stage background colour. Can anyone help with the AS3 code? Thanks.

you have to use the bitmapdata class to determine pixel color but i'm not sure that makes sense for whatever you're trying to do.  to be sure, you can't determine the stage color using it.
in addition, there is probably a better way using hitTestObject or hitTestPoint to do whatever you want.

Similar Messages

  • How to get pixel colour?

    Is there any way to get pixel colour from specified point? Example: colour = image.getPixel(x, y);
    J2ME/MIDP 1.0
    Thanks!

    {color:#800000}*I am happy to compare the two pixels of same image using this code in Java:*
    {color}
    Image ori, nw;
    public void init()
    { ori = getImage(getDocumentBase(),"flower.jpg");
    int pxl[]= new int [65536];
    PixelGrabber pg = new PixelGrabber(ori,0,0,256,256,pxl,0,256);
    // Image is stored into Array
    try{ pg.grabPixels(); }
    catch(InterruptedException e) {}
    for(int i=0;i<65536;i++)
    { int p = pxl[i];
    int ri = (0xff & (p>>16));
    int gi = (0xff & (p>>8));
    int bi = (0xff & p); // Take the RGB value of each pixel
    for(int j=0;j<255;j++) // Chk. other similar pixel in color range of 0 to 255
    int q = pxl[j];
    int rj = (0xff & (q>>16));
    int gj = (0xff & (q>>8));
    int bj = (0xff & q);
    if ( (ri==rj)&&(gi==gj)&&(bi==bj)&&(!(i==j)))
    { ri+=70;//if (ri<0) ri = 0;
    gi+=70;//if (gi<0) gi = 0;
    bi+=70;//if (bi<0) bi = 0;
    pxl[i] = ( 0xff000000|ri<<16|gi<<8|bi); // Change value
    else
    pxl[i] = ( 0xff000000|ri<<16|gi<<8|bi);// Keep as it is
    Email : [email protected], Profile: www.aribas.edu.in/Mr.Brijesh_Jajal.htm

  • Changing Pixel Colours

    Hi,
         Is there a way of changing pixel colours in (say) a Graphics (or image) object? I want to be able to create a Graphics object, and then change pixel colours, as determined by the results of a numerical simulation, as results are generated.
    Any help appreciated!

    You can use the drawLine to draw a one-pixel line in the right place.
    Alternatively (and probably better) use an int array to contain your image data and use a MemoryImageSource to generate an Image for display from that.

  • Accessing pixel colours for 2 layers

    Hi,
    I know I'm probably missing something but I can't seem to get my head around how to access what colours individual pixels are.
    I suppose I should briefly describe what I'm trying to do so here goes. I need to make a photoshop plugin for a college project. The functionality required has been provided to me in the form of an external dll which I need to call. Two of the paramaters needed to do this are linear unsigned char arrays for the entire two images which have values for each pixel dependent on their colours . The plan is to have the background layer be the image the user wants to modify and a second layer where the user indcates what they want to modify by making strokes of varying colours. As such I need to create these char arrays based on the pixel values. The background one will simply be a case of storing the colours as unsigned chars and the second one will require assigning specific numbers based on the colours.
    From what I have read the ReadPixelsFromLevel(...) function seems to be my best bet, although I could be wrong there, but I'm not quite sure what to do with the destination once values have been read there.
    Any insight would be appreciated as my deadline is looming ever closer and my progress has stalled somewhat.
    Thanks.

    I think your assumption was right, you just need to get different channels descriptors for ReadPixelsFromLevel function.
    you can obtain them from the filterRecord->documentInfo structure.
    filterRecord->documentInfo->targetCompositeChannels is your writable channel (eg. red).
    if you want to read from the layer other than active, you should first get the layersDescriptor and then its channelDescriptor,
    eg.  filterRecord->documentInfo->layersDescriptor->compositeChannelsList.

  • Questions about: Checking pixel color , moving the mouse , checking sound.

    Is it possible to check the color of pixels on the screen (not just in a jframe) ?
    Is it possible to use java to compare sounds being played by a program that is running with sound from a file ?
    Is it possible (when using the robot class to move the mouse) to make it so that java is running only in the background (ie. have something else running in the foreground) ?
    Is it possible to make a tray icon appear next to the system clock when a java program is running ?
    Are there any differeces when running programms on windows, linux and/or mac ?

    Is it possible to check the color of pixels on the screen (not just in a jframe) ?
    Is it possible to use java to compare sounds being played by a program that is running with sound from a file ?
    Is it possible (when using the robot class to move the mouse) to make it so that java is running only in the background (ie. have something else running in the foreground) ?
    Is it possible to make a tray icon appear next to the system clock when a java program is running ?
    Are there any differeces when running programms on windows, linux and/or mac ?

  • Pixelated coloured fonts ...

    I put a blue text layer (the name of the shown person)
    on top of a clip, but unfortunately the text is blurred and pixelated
    at the edge.
    I built it in FCP and in BORIS.
    If I change the colour to black or white, the edges are fine!
    Does anyone have an idea, how the get a sharp edge on a blue text?

    Sorry, wrong forum!

  • How do I check which colour space my monitor uses?

    When I go to Sys Prefs > Displays > Color and open the currently-used profile it says (among other things):
    Space: RGB
    Platform Apple
    Is the colour space used Apple RGB? I also don't find this info in System Information or Color Sync.
    I wish to assign Adobe RGB to harmonise with my scanning program. How do I assign another profile?
    TIA
    Philip

    Hi Danny,
    You can use the methods below to get the version/service pack level:
    1) Manage a webserver instance and click on "About this server"
    2) Look at the startup message in an error log
    3) ./start on the start script
    4) ./ns-httpd -v in the /<server root>/bin/https/bin directory

  • Checking pixels from call to:  grabPixels();

    I am using pixel grabber to grab the pixels in an image. Then once I have the pixels, I want to know how many of the pixels are Transparent.
    I am loading a total transparent image to test with. The problem is that when I examine the contents of the array image_array, the values are all 0 (Zero ). This means the color of the pixel is black.
    Which I think somehow equates to Transparent. But I thought transparent is: 0x01FF01
    ??? Help I am lost? Here is the code. I have included comments on
    lines 23,25,26. Thanks in advance, Amy Danough
    1 temp = getImage(getDocumentBase(),"sky.gif");
    2 MediaTracker tracker = new MediaTracker(this);
    3 tracker.addImage(temp,0);
    4 try { tracker.waitForID(0);
    5 }catch (InterruptedException e) {return;}
    6
    7
    8 int widths = temp.getWidth(this);
    9 int heights = temp.getHeight(this);
    10 int[] image_array = new int[widths*heights];
    11
    12 try {tracker.waitForID(0);}
    13 catch (InterruptedException e){}
    14
    15 PixelGrabber pg = new PixelGrabber(temp,0,0,widths,heights,image_array,0,widths);
    16 try { pg.grabPixels(); }
    17 catch (InterruptedException e) {}
    18
    19 int count = 0;
    20 int rgb;
    21 for (int i = 0; i < widths*heights; i++) {
    22 rgb = image_array[i]; // get a pixel from the array
    23 if (rgb == 0x01FF01){ count++; } // I am thinking tranpsarent == 0x01FF01
    24 }
    25 // Count always returns Zero for my totally transparent image.
    // The value rgb at line 22 always equates to Zero ???

    Don't use Toolkit.getImage()/createImage(), use javax.imageio.ImageIO.read(...)
    or, if u do use the toolkit methods, copy the image into a BufferedImage before you start messing around with the pixels.
    BufferedImage offers much better ways of maipulating the pixels directly. (without having to make a copy of them [which is what pixel grabber does])

  • Reading colour image using raster object and getsample() method

    Hello all,
    I am trying to read a grey image using this code below and it perfectly works:
    File filename = new File("myimage.jpg");
    BufferedImage inputimage = ImageIO.read(filename);
    Raster input = inputimage.getRaster();
    double pixelvalue = input.getSample(xx, yy, 0) ; // to read pixel colour.
    Now:
    what modifications should i do to read a colour image using getsample() method.
    any help, by example if y would.
    Thanks

    The code below
    double pixelvalue = input.getSample(xx, yy, 0) ; // to read pixel colour.actually doesn't obtain the pixel color. It reads a band of the specified pixel. If you are reading a tripple band image (24-bit colored image RGB ) then you have to invoke this method three times for band 0, 1 and 2. The arrangment of them depends on the BufferedImage type.
    In reply of your question, you can use getSamples method, refer to the java API documentation of the BufferedImage class for more info.
    you can also check methods getRGB and setRGB, they used to get/set the entire pixel in range of 0x00000000 to 0x00FFFFFF ( 0x00RRGGBB of image type TYPE_INT_RGB )
    Regards,
    Mohammed M Saleem

  • Vertical "Stipes" of Pixels over whole screen-cursor is 1 cm block

    I've a 15" Ti PB--550 MHz. When started up in OSX-10.4.2 it comes on with a pattern of vertical whitened pixels and alternate darker coloured (about 1 cm wide) blocks of pixels over the whole screen. No icons appear and no menu. The cursor appears as a greyed out block of pixels about 1 cm square. The F10 key changes the pixel colour and pattern. When started up in "T" mode, all the Hard Disk icons are seen normally on another Mac and all files are intact. Is this a "wire" harness problem in the hinges; a wire cable connection to the Logic board ? The wires in the cable connection and hinge area look fine ...What sort of problem is causing this? Anyone have an idea ?

    Dear dago,
    Thanks much for your reply. Actually, my oper. system is 10.4.4 as well I think--I have not verified it lately of course because of my display screen problem as I've outlined and which you have confirmed as well as a problem. The problem , ie. the strips of alternating vertical coloured pixels and white, seem to run down the screen rather continuously; if I depress f8, f9 or f11 the pattern of the pixels changes but still is observed overall the screen. I see no file or program icons, no menu, no dock information, nothing other than these annoying "noise" pixels illuminated.
    But, you say you see this pattern "at least once a week"..the pattern I see is constantly there. It is there the moment I boot up until I depress my power button to shut down. You also said it "might" be a logic board problem; perhaps it could also be due to the inverter board or some other problem circuit board, I have no idea really. I have checked my cable-board connections; all looks normal to me. If I set up in "T" mode, I can see all my icons and files normally on another Mac used to display my problem machine..
    Please let me know if you discover something further on this..My machine is only in a state now where I must boot it up in "T" mode using another Mac to view my problem machine. It goes without saying I cannot work efficiently in this mode for long.
    Let's hope at least one of us can come up with some answers to this. Thanks again for your interest and keep your remarks coming if you've time and energy.

  • How can i load or put an image into array of pixels?

    i am doing my undergraduate project , i am using java , mainly the project works in image manipulating or it is image relevant , few days ago i stucked in a little problem , my problem is that i want to put an image scanned from scanner into array or anything ( that makes me reach my goal which is go to specific locations in the image to gather the pixel colour on that location ) , for my project that's so critical to complete the job so , now am trying buffered image but i think it will be significant if i find another way to help , even it isn't in java i heared that matlab has such tools & libraries to help
    thanks .....
    looking forward to hearing from you guys
    Note : My project is java based .

    Check out the PixelGrabber class: http://java.sun.com/j2se/1.5.0/docs/api/java/awt/image/PixelGrabber.html
    It's pretty simple to get an array of Color objects - or you could just leave it as an int array - though it can be somewhat slow.
    //img - Your img
    int[] pix=new int[img.getWidth(null)*img.getHeight(null)];
    PixelGrabber grab=new PixelGrabber(img,0,0,img.getWidth(null),img.getHeight(null),pix,0,img.getWidth(null));
    grab.grabPixels();  //Blocks, you could use startGrabbing() for asynchronous stuff
    Color[] colors=new Color[pix.length];
    for(int in1=0;in1<colors.length;in1++){
    colors[in1]=new Color(pix[in1],true);  //Use false to ignore Alpha channel
    }//for
    //Colors now contains a Color object for every pixel in the image//Mind you, I haven't compiled this so there could be errors; but I've used essentially the same code many times with few difficulties.

  • Colour change/tone between Raw image and elements 9 image

    Elements 9. Recently started having this problem that was not there when I first installed E9 I set the picture up in RAW and all seems well with result as I want it. When then opening elements from the RAW image, the image shown to me in elements is noticeably darker and has colour variation on it. Basically I can't trust the elements image to be reflective of what prints out or the RAW image. This is more than annoying now.... I'm reluctant to re-install as I don't want to experience any new problems as a result. Any thoughts on this from anyone please?

    OK, checked the colour settings. Everything was set like you suggested.
    But the problem has been way less noticeable during the past months. Maybe because I made a recalibration some time ago. The screendumps I attached where made this spring. So there might be a chance my monitor profile was corrupt back then, but got OK since i recalibrated.
    I'll do some more tests, saying thanks for now for the quick reply.

  • [Repost] DisplayPort HDMI Colour Problems

    This is a repost from the MacBook Pro forums - hoping someone here might be able to help
    I've got a late 2011 MacBook Pro (with the Radeon 6770M card).  When certain conditions are met:
    1. The machine is booted with the lid closed (it sits in a BookArc stand);
    2. It is connected to an external display via the DisplayPort connector to an HDMI display;
    3. It is booted into Windows under Boot Camp; and
    4. The laptop lid is opened after boot.
    ...then the colour goes all... screwy.  Here's what I mean.  First picture is what the display colour should look like (as shown on the external monitor).  Second picture is what it looks like on the MBP's inbuilt screen.
    This is driving me bananas.  I've tried a couple of different things:
    1. Boot Camp 4.0 drivers;
    2. Boot Camp 4.1 drivers;
    2a. Boot Camp 5.0 drivers;
    3. A different monitor cable;
    4. A different external monitor;
    5. A complete rebuild of OS X and Windows;
    6. AMD native beta drivers (13.5).
    Nothing's fixed it.  I used to have a similar MBP, but with the 6750M card and that worked fine with the same connectors/stand/monitor/etc.  The workaround is to boot it with the lid open, which is kind of a pain (in a first-world-problems kind of way).
    I'm guessing there's a magic setting inside either Boot Camp control panel or drivers or even Windows itself that controls how it behaves with external monitors and colour settings and stuff like that, but I can't work it out.
    Help?

    I have also tried Boot Camp 5 (5.0.2) drivers, no dice.
    And spent hours mucking about with the Catalyst Control Centre for things like pixel colour format, and assigning different profiles using Windows Colour Management.
    I'm getting the strong feeling this is something quite specific to how the card is initialised in certain states, and at a level low enough to be hidden from the user.

  • Check printing with out bank details amount etc

    Hi Gurus,
    When I am running APP it is running perfectly when I am looking in own spool request I am getting the check details but in check column Bank Details XXXXXX
    Check Number XXXXXX  Void
    I am not able to get the check details

    Hi hatstead
    Under Image Mode:   RGB colour is checked
    Edit>colour settings the “Always Optimise Colours for Computer Screens” is checked
    File>Print>More options>Colour management tab>colour handling I have “Photoshop Elements Manages Colour”
    Just as a check, a while ago  I ran the same photo under “Printer handles colour” and the result was even worse.
    I wondered whether Edit>Colour should have “Always optimise for Printing” checked?  But I have never seen that menu before, so presumably the “Always Optimise Colours for Computer Screens” has been checked even whilst printing from PSE 10 with good results.
    Kind regards
    Sarah

  • Colour change when opening LTRM image in PS

    My question is as simple as this:
    In Lightroom my RAW (NEF) image looks like this:
    After conversion in LTRM from RAW to PSD, it looks like this
    See how greyish the PSD version is. Just like if someone had cranked the saturation slider down before the conversion. And yes, I did check the "Edit Image in Photoshop with Lightroom adjustments".
    Why does this happen?

    OK, checked the colour settings. Everything was set like you suggested.
    But the problem has been way less noticeable during the past months. Maybe because I made a recalibration some time ago. The screendumps I attached where made this spring. So there might be a chance my monitor profile was corrupt back then, but got OK since i recalibrated.
    I'll do some more tests, saying thanks for now for the quick reply.

Maybe you are looking for

  • Is there a way to delete an app when you can't see the app's icon?

    Is there a way to delete an app when you can't see the app's icon? I have so many apps that they don't all show up on the existing screens. I know it can be done by connecting to a computer and using iTunes, but I'm on the road away from my Mac.

  • Saving Excel Files to CD-RW

    For some years now I've been able to insert a CD-RW disc, double click on an Excel file stored there, open the file, edit the file, then simply resave the file under the same file name back onto the CD-RW disc. Seemingly, suddenly I am no longer able

  • Is that the normal behavior of ImageReader?

    When javax.imageio.ImageReader reads frames of an optimized animated gif (where only the changes in each frame are saved), it will only return a small portion of the image when it falls on an optimized frame. So let's say an animation has the size 50

  • Versions difference in ecc 6.0

    Hello experts,     What are the major and minor difference between the 4.6c and ECC 6.0 Please tell me the diffences Thanks Raghava

  • How to configure snmp on loopback interface, on vrf TEST, in ASR 9000 series

    Hi there! How to configure snmp v2, with community string, for ASR 9000 series, in interface loopback 1, that has vrf TEST Regards!