A strange one - setPixels only works against the left of the screen

setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize)My applet's split into different bits. The main game screen (which I'm animating to with pixel[]) starts in the top left hand corner...
_consumer.setPixels(0,0,ScreenWidth,ScreenHeight,_model,(int[])pixel,0,ScreenWidth);ScreenWidth and ScreenHeight are the dimensions of the main game screen. There's a stats area to the right, but that's just done with Graphics.drawString, etc..
Anyway, I want the statbox to go on the left, so I need the main screen to get drawn on the right. No problem, right?
_consumer.setPixels(StatboxWidth,0,ScreenWidth,ScreenHeight,_model,(int[])pixel,0,ScreenWidth);
java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at sun.awt.image.IntegerInterleavedRaster.setDataElements(IntegerInterleavedRaster.java:359)
        at sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java:484)
        at Strib.update_consumer(Strib.java:197)
        at Strib.paint(Strib.java:99)
        at Strib.run(Strib.java:187)
        at java.lang.Thread.run(Thread.java:484)The only way i can increase x at all is by decreasing w by the same amount, giving me a smaller main screen. I've tried changing the offset up or down just in case but that doesn't help. What am I missing?
Thanks for your help!

you only call consumer.setPixels() once at the end of the frame.
all the drawing goes into your pixel[].
the width in setPixels() is being added to the x. since the width is the max value its overflowing.
public void run()
   while (running)
      render();
      update(pixels);
      try
         thread.sleep(threadDelay);
      } catch (InterruptedException e)
public void render()
   java.util.Arrays.fill(pixels, 0x000000); // fill the screen wiht black 
   writePixel(100,100,0xFF0000); // put a red pixle at 100-100
public synchronized void update(int[] pixels)
   if (consumer != null)
   // copy integer pixel data to image consumer
   consumer.setPixels(0, 0, width, height, model, pixels, 0, width);
   // notify image consumer that the frame is done
   consumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
   paint();
private synchronized void paint()
   // draw the back buffer image onto the screen
   getGraphics().drawImage(image, 0, 0, width, height, null);
public final void writePixel(int x, int y, int color)
   int i = width * y + x;
   if (i >= 0 && i < size)// size = screen width * height
      pixels[i] = color;
}

Similar Messages

  • I purchased Adobe photoshop elements II and Adobe premiere elements II. They are both on one disc. My computer crasded and I had to reload Windows. I only have one serial number and it only works with photoshop II. The same serial number will not work for

    I purchased Adobe photoshop elements II and Adobe premiere elements II. They are both on one disc. My computer crasded and I had to reload Windows. I only have one serial number and it only works with photoshop II. The same serial number will not work for Premiere. I dont have any other serial numbers. What do I do???

    Static_Unit
    I am getting a bit concerned about what is happening in your situation. Yesterday you posted your question in at least two different forums, one of them being here in the Premiere Elements Forum.
    Don't Have Serial Number for Premiere, Only Photoshop?
    Wherever you posted, the reply was to contact Adobe via its Adobe Chat. It is the only one who can sort out this matter for you.
    In the thread cited above I offered to help you with the difficulties that you were having visualizing the Adobe Chat in its web page. I was waiting for your follow up on that in the above thread. Instead, I find your same question in a new Adobe Premiere Elements Forum thread this afternoon with no refer the prior threads or prior recommendations given you.
    I will also mention again...when you buy the Photoshop Elements and Premiere Elements bundled in one packaging and with installation files for each on the same installation disc, each program has its own serial number. The Photoshop Elements serial number does not work for Premiere Elements and vice versa. The serial numbers are on labels on a box which houses the installation disc envelope(s). So, if you purchased both programs and found the Photoshop Elements serial number, then the Premiere Elements serial number should be in a label right underneath the label with the serial number for Photoshop Elements. I recall writing this in your yesterday's thread on this matter.
    The moderator will no doubt be along shortly to close or delete this thread. So, just in case, please bookmark your yesterday's thread cited above so that we can continue this communication which is trying to help you.
    Thanks.
    ATR

  • What should i do my sleep/wake button on iphone 5 does not work properly it only works if i press on the left side of it and my iphone still on warranty i heard its a common problem

    what should i do my sleep/wake button on iphone 5 does not work properly it only works if i press on the left side of it and my iphone still on warranty i heard its a common problem

    If there's a hardware defect and your phone is under warranty, bring it to Apple for replacement.

  • I just bought a new macbook air and while transferring documents from my old computer to my new one it stopped working, how do I restart the transferring process (it won't force quit on the new one)?

    I just bought a new macbook air and while transferring documents from my old computer to my new one it stopped working, how do I restart the transferring process (it won't force quit on the new one)?
    I NEED HELP

    jesster03 wrote:
    i just bought a new macbook w/ mtn lion. when i transferred data from my old macbook over, it created another user name (i called it "old computer"). That's actually good
    That's actually bad. Peruse Pondini's Setup New Mac guide and seriously consider starting over.

  • Hello guys,My first time in community.my problem is that my SIM card was working ok and from today at the left of the screen up shows that is searching for the sim.I contacted the carrier and the SIM card shows that is working.Any suggestions?

    Hello guys,My first time in community.my problem is that my SIM card was working ok and from today at the left of the screen up shows that is searching for the sim.I contacted the carrier and the SIM card shows that is working.Any suggestions?

    Hey NicolasZen,
    Thanks for the question and welcome to the Apple Support Communities. I understand that you are experiencing issues with “No Service” or “Searching” on your iPhone. The following resource provides some great troubleshooting steps that you may wish to try:
    iPhone: Troubleshooting No Service
    http://support.apple.com/kb/TS4429
    Your iPhone may have one of these symptoms:
    - iPhone displays "No Service" or "Searching" in an area of good coverage
    - iPhone doesn't regain service when returning to an area of coverage
    Resolution
    If you encounter either of the above symptoms on your iPhone, follow these steps to attempt to resolve the issue. Test after each step.
    1. Toggle airplane mode: Tap Settings > Enable Airplane Mode, wait five seconds, then turn off airplane mode.
    2. Turn iPhone off and then on again.
    3. Remove the SIM card and verify that it's a valid, carrier-manufactured SIM. Also verify that it isn't damaged, worn, or modified. Then reinsert it.
    4. Check for a carrier-settings update. Connect to a Wi-Fi network. Then tap Settings > General > About. If an update is available, iOS will ask you if you want to install it. If Wi-Fi isn't available, connect your device to iTunes.
    5. Update your iPhone to the latest version of iOS.
    6. Reset network settings by tapping Settings > General > Reset > Reset Network Settings. This will reset all network settings, including Bluetooth pairing records, Wi-Fi passwords, VPN, and APN settings.
    7. Restore the iPhone.
    Thanks,
    Matt M.

  • When i open facebook and only text shows and all is to the left and when i open hotmail nothing shows on my screen and other webpages have problems also when click at a link all the text comes up also to the left in my screen whats wrong ???

    When i open facebook and only text shows and all is to the left and when i open hotmail nothing shows on my screen and other webpages have problems also when click at a link all the text comes up also to the left in my screen whats wrong ???

    Clear the cache and the cookies from sites that cause problems.
    * "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites causing problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    See also:
    * http://kb.mozillazine.org/Websites_look_wrong
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * [[Troubleshooting extensions and themes]]
    In Firefox 4 you can use one of these to start in <u>[[Safe mode]]</u>:
    * Help > Restart with Add-ons Disabled
    * Hold down the Shift key while double clicking the Firefox desktop shortcut (Windows)

  • My tool bar (the one that is usually to the left - not the palettes on the right) has disappeared.  How do I get it back?

    My tool bar (the one that is usually to the left - not the palettes on the right) has disappeared.  How do I get it back?

    Window > Tools

  • I have coloured vertical lines about a quarter of the way from the left of the picture when using my apple tv 2. Anyone got any idea what is causing it. Have done a reset but still same. ATV2 is only a month old.

    I have coloured vertical lines about a quarter of the way from the left of the picture when using my apple tv 2. Anyone got any idea what is causing it. Have done a reset but still same. ATV2 is only a month old.

    Just to make sure, try a different set of cables. If the problem persists, have the unit replaced by Apple.

  • When I have more than one tab open, if I click on a picture to view, when the window opens to view the photo, firefox crashes. I also notice while looking at a web page, the pinned tabs to the left of the bar are constantly reloading for some reason.

    When I have more than one tab open, if I click on a picture to view/enlarge, say eBay, and I click on the items photo to enlarge it, when the window opens to view the photo, Firefox crashes. I also notice while looking at a web page, the pinned tabs to the left of the bar are constantly reloading for some reason, The green circle starts going round and round for no reason even though the tab is not being viewed. Both problems seem to have started after the last software update.

    See:
    * http://kb.mozillazine.org/Firefox_crashes
    * https://support.mozilla.org/kb/Firefox+crashes

  • Iphone fell down and there is a very big dent on the left side. the screen split on both side. can i send it to apple and the repair it for like 160€ or how does it work?

    hi my iphone fell down and there is a very big dent on the left side. the screen split on both side. can i send it to apple and the repair/change it for like 160€ or how does it work?

    Service Answer Center - iPhone - http://support.apple.com/kb/index?page=servicefaq&geo=US&product=iphone  <-- enter correct country in drag-down menu once on page.

  • Red light to the left of the receiver of the iPhone 5

    I had my iPhone 5 replaced at the weekend for a speaker issue, but I noticed today when using the replacement in a dark room, I can see a glowing red light to the left of the receiver. I did a search, of course, which brought up results concerning the iPhone 4 and that it's the proximity sensor and not something to worry about. But I also saw this "eHow" article that says it's because the phone's been exposed to water:
    http://www.ehow.com/info_8704998_red-light-iphone-mean.html
    Earlier today I was using the phone when it started raining, so I quickly wiped it against my sweater and put it in my inside jacket pocket. I didn't think that would be enough to cause any damage to the phone and the phone is working fine, but now I'm a bit worried, having not noticed the light before.
    Is the eHow article wrong or do I have a reason to be worried?
    Thanks in advance for any help.

    That's one of the most absurd things I've ever read...the light is part of the proximity sensor. The sensor is an infrared light that can appear red when viewed through the front glass in a very specific way in the dark (the glass distorts the infrared light enough to make it very weakly visible). This is totally normal and nothing to worry about. The water sensors are round white stickers in certain locations on and in the iPhone. When they get wet they turn red and do NOT turn back. The sensors wouldn't be very useful if they changed back when the phone dried...

  • Is the left-hand Home screen reserved for TV and movies?

    As familiar as I thought I was with Android (via my phones) I thought I would've figure out by now how to get this screen back for other uses. But so far no luck.  Is 1//3 of my available Home screen space really reserved for TV and Movies (and, at that, apparently only the ones downloaded from Google Play)?

    Ann154,
    Bingo! You were absolutely right! And now that widget is gone.
    Unfortunately, so is the screen it was occupying. Now,  instead of three screens I have but two - - the original center screen and the one that had previously been the right-hand screen.
    Which prompts the question of how and where pages are added or deleted from the home screens.
    Sent from myMail app for Android
    Sunday, 28 December 2014, 09:05AM -07:00 from Ann154 <[email protected]>:
    A message from the  Verizon Wireless Community
    Is the left-hand Home screen reserved for TV and movies? created by  Ann154 in  Verizon Ellipsis 8 -  View the full discussion

  • In Mail, I can see the list of messages on the left but the message that is highlighted doesn't display on the right.

    Where is my mail message?  The list of emails with preview is on the left, but the pane on the right only contains the sender and subject, no content.

    Try turning the account off and on : Settings > Mail, Contacts, Calendars , then tap the account on the right, slide Mail to 'off', exit settings and go back into the Mail app, and then go back to Settings and slide Mail back to 'on'
    If that doesn't work then try closing the Mail app completely : from the home screen (i.e.not with the Mail app 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Mail app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    Also do a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • Websites appear distorted; just random info along the left side of screen from major sites like UPS/Fedex.

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/923529]]</blockquote>
    Major sites appear as text items just along the left of the screen (like UPS and Fedex and many others).
    IE and Chrome work fine. "Basic Styles" is in effect. Java is activated. I tried everything I could think of in tools/options/addons and even rebooted and firefox is still malfunction.
    This makes me sad (and should make firefox/Mozilla sad too).

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode

  • With the left panel, trying to use the Presets, in the tutorial to the left of the commands there are square icons, for example "Lightroom B

    With the left panel, trying to use the Presets, in the tutorial to the left of the commands there are square icons, for example “Lightroom B & W Presets”. On my program they are arrowheads pointing to the right. When I click on any Preset, it does not work.
    Also, Right Panel, Color, White Balance, “As Shot” only has 2 options (auto & custom) vs. tutorial that has 9 options.

    You are not supposed to connect a pair of speakers(as in left and right in a stereo pair)to two separate out jacks on the sound card.the place on the card where headphones/speakers with the mini jack goes is the right place.

Maybe you are looking for

  • Alter label colors when using DefaultTreeModel

    I have a JPanel with a bunch label and text fields that I organize using the DefaultTreeModel. What I have noticed is I cannot seem to alter the label text in any way. Is the model overriding my settings to things like Forground Colors? Is there a wa

  • Archive Link & Cost Center

    Hi all, I have attached document to cost center through Archive Link tr.code OAWD succesfully. but i can't see any document attach in cost center(Tr. Code KS02).where to find this attach doucment throgh Archive Link with cost center. i allready check

  • Macbook Pro Batteries and Fans Whirring

    I have a Macbook pro. It is only 2 months old and since the logic board was replaced due to a fault twice I have had the battery symbol at the top coming up with an x in it (power not connected) and the fans have been whirring inside. I have to unplu

  • My windows phone 8 nokia lumia 920 doesn't show up in finder

    I have a macbook pro laptop and want to download some music files to my windows phone from finder. I don't want to use the official windows phone app, where it shows up, but I do not prefer this app because it allows me only to upload full albums to

  • Object oriented and structured paradigms

    Hi, I'm trying to find information which compares the OO and structured paradigms, but im finding it to find any information on google. I was wondering if there is another name for structured programming? Is imperative or functional programming the s