Old game developper not used to new APIs...

Hi all,
About 3 years ago I was working for Ubisoft building Java games. Back then (jdk 1.1.8), the fastest way to produce images with effects and all was to manipulate the image as an array of pixels (int[], ARGB) and to use a MemoryImageSource to produce the image.
Now I feel like building a game for the fun of it, but I'm lost in all the new stuff they added. First of all, I just wanted to have an image built on an array of pixels. So I tried the following code :
DirectColorModel model = new DirectColorModel(32,0x00ff0000,0x0000ff00,0x000000ff,0xff000000);
WritableRaster raster = model.createCompatibleWritableRaster(640, 480);
int[] array = new int[640 * 480];
for (int i = 0; i < array.length; i++)
array[i] = 0x00ff0000;
raster.setPixels(0, 0, 640, 480, array);
BufferedImage img = new BufferedImage(model, raster, true, null);
panel.getGraphics().drawImage(img, 0, 0, this);
First, I get an ArrayIndexOutOfBounds on the setPixels() call. Why is that ? I mean, I specified the width and height to 640 * 480 but seems that the raster does not have the same widht and height ???
And second, if I use like setPixels(0,0,40,40,array), it displays some weird color scheme but in the array, I set all the pixels to 0x00ff0000 (red).
Could anyone help to get started ? I guess I am missing something here.
BTW, if anyone is interested in having a colloection of nice functions to manipulate arrays of pixels, I can send my old collection through e-mail.
Max, former game prog, but da** lost in all this...

Could anyone help to get started ? I guess I am missing something here.Useful API documentation? The whole area of Rasters seems to me to be thoroughly undocumented.
I don't know whether you've had a look at the source code for java.awt.GradientPaintContext (it's a package-private class). Rather than use setPixels(int, int, int, int, int[]), they use internal knowledge about the type of WritableRaster returned.
I think that if you want to understand what's going on, you'll have to wade through the source code (and it's not at all well commented).
Incidentally, what wierd colour scheme do you get? Is it a consistent block of colour, and if so can you paint your image onto a BufferedImage and use getRGB(int, int) to find out its value?

Similar Messages

  • Diablo 1 not working at all, 12 year old game does not work on new computer

    Hello, I have a Toshiba Satellite P200 with Windows Vista 32 bit, it has a ATI Mobility Radeon HD 2400 video card. I also have Direct x 10 installed which according to the manufacturers of my video card is compatible. I have run a game test which was included with the CD and it says everything is o.k. But it is still coming up with this error. "Diablo was unable to properly intialize your video card using directX" then it tells me to update my directx which i have done. check and update my driver for my video card and make sure its compatiable which i have done and know it is. I have been to Blizzard Games and they have said that can not help me and i will have to go to the manufacturer of the video card. I Went to them and they said because it was a laptop they can not help me with this and told me to goto the manufacturer of my laptop which i am doing at the moment, but if anyone else has had this problem and has any ideas how i can get this running please tell me thankyou.

    This game was designed for Windows 95. Many older games wont run under the NT kernel (under XP and Vista) unless you use emulation such as DOSBox.
    You could try setting the game to run in Windows 98 compatibility mode (Right click the games EXE file, choose Properties -> Compatibility Tab).
    Otherwise you may need to install Win95/98, and possibly use an older Video Card since the display drivers change so rapidly and drop legacy features not used anymore.

  • Just got a new MacMini.  Migrated files using Time Machine.  However, now, on Launchpad, I see several Firmware updates that were relevant for the old machine, but not for the new one.  How do I get rid of these updates?  They won't delete!

    Just got a new MacMini.  Migrated files using Time Machine.  However, now, on Launchpad, I see several Firmware updates that were relevant for the old machine, but not for the new one.  How do I get rid of these updates?  They won't delete!

    Only thing I can think of is trying this Lion trick...
    http://www.cultofmac.com/106030/how-to-nuke-lions-launchpad-and-start-over/10603 0/

  • Not able to update any apps from new apple id.. Old id im not using anymore., cannot access the old one

    Not able to update any apps from new apple id.. Old id im not using anymore., cannot access the old one.. But during update time asking for same old password of old apple id

    If you change your Apple ID, all the apps you purchased with the previous ID will no longer updatable for you and this problem will continue. You see your old Apple ID because you are likely still using some of the apps purchased on that ID.

  • HELP! My old mac was requested to upgrade Firefox to 14.0.1. After the sucessfully installation, I received a message saying my old Mac couldn't use the new Firefox and Safari crashes. I have NO browser now!!!

    My old mac was requested to upgrade Firefox to 14.0.1. After the sucessfully installation, I received a message saying my old Mac couldn't use the new Firefox and Safari crashes. I have NO browser now! Any help would be appreciated.

    Hmmm...  So you upgraded Firefox and now neither Firefox or Safari will work?  Very weird.  I have no idea what might have gone wrong.  That said, when things start acting wierd, I always try a bit of maintenance first.  About 95% of the time, I luck out and it works.
    I use the free program Onyx.  I run all the clean up routines.  Then I boot to the recovery partition (Lion) or the OS X Install Disc and repair permissions and verify/repair the hard disk.
    Hope this helps.

  • S my computer will on itunes said that it will not use my new ipod touch because it says that service is not started. I have registered my new ipod touch and am trying to download stuff from my itunelibrary. Ps help!

    my computer will on itunes said that it will not use my new ipod touch because it says that service is not started. I have registered my new ipod touch and am trying to download stuff from my itunelibrary. Ps help!

    Try:
    iPhone, iPad, iPod touch: How to restart the Apple Mobile Device Service (AMDS) on Windows

  • I just downloaded Firefox 5 and it said that my Yahoo toolbar will not work with it. Is this true? If so I will not use this new version and will switch to another browser if Firefox stops supporting the Yahoo toolbar. Thank you.

    I just downloaded Firefox 5 and it said that my Yahoo toolbar will not work with it. Is this true? If so I will not use this new version and will switch to another browser if Firefox stops supporting the Yahoo toolbar. Thank you.

    Add-ons contain a range of compatible Firefox versions, and Firefox honors the listed range by disabling the add-on if you are trying to run it on an unlisted version.
    I'm sure Yahoo! will update its toolbar eventually, but not every add-on maker supports beta versions of software.

  • I have an old AOL account not used for years. No I have realized some years ago I have signed in into the apple storewith this email. Now I am not able to change this apple ID. Has s.o. an idea how to work this out?

    I have an old AOL account not used for years. No I have realized some years ago I have signed in into the apple storewith this email. Now I am not able to change this apple ID. Has s.o. an idea how to work this out?

    See this -> http://support.apple.com/kb/TS1299

  • HT1918 how do i delete an old email address and use a new one as my primary?

    how do i delete a primary email address and use a new one?

    Stop using the old one and start using the new one. Notify all your friends, family, etc. of the change in email address.
    iTunes Store: Changing Account Information

  • HT201303 Trying to download a song from iTunes.  Message claims I need to "update" my billing info because I am "using a new device".  I am not using a new device.  How do I know this is genuine?

    Trying to download a song from iTunes, I get a message asking me to update payment details because it claims I am "using a new device."  I am not using a new device.  How do I know if this is genuine?

    (Typing all in capitals is considered shouting, makes posts difficult to read and may mean that people are less likely to reply.)
    There isn't a phone number for iTunes Support.
    If you've forgotten your answers to your security questions then you can get them reset : If you forgot the answers to your Apple ID security questions
    If you have a credit card on your account then its details have to complete - and asking for their details is also a way of checking that you have a valid billing address in that country. As long as you are buying content for yourself and not trying to gift content (you can't use your balance for gifting) then the purchase price (plus any applicable taxes) should be deducted from your balance. If it's not then you contact iTunes Support :  http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Replacing Time Capsule - can I save my old config file to use with new one?

    I have a Time Capsule backing up 3 of my Macs. A couple of nights ago, I started receiving the following: "sparsebundle” could not be created error 22
    on all 3 Macs.Time Machine application fails due to this error and if I access the Time Machine in Finder, I can see the 3 volumes but cannot go any deeper. I get the same sparsebundle error.
    A few minutes ago, my wife called me stating that her MBP gave her a backup error stating that the backup Volume name changed, continue or don't backup. Something weird is obviously going on. I also noticed that the TM fan was kicked up into high gear. I'm suspecting a hardware failure of some sort.
    Thoughts?
    If I do need to replace my TC, is there a way to save the config file from my old one and import/use it on a new TC if I have to purchase one? Would save me from entering a lot of wireless access devices since I use MAC filtering.

    Yes you can easily import/export settings ( I have 6 base stations so do this quite a lot - in fact I always export the configs as a backup anyway)
    As to your TC can you connect it locally and run Disk Utils to see if it need some repairs?
    Regards,
    Shawn

  • I have transferred itunes and library using home sharing.  How do I 'turn off' the old computer and just use the new one?  home sharing requires both to be on at the moment.

    I have transferred my itunes content and playlists to a new computer using home sharing.  Now I want to use my new computer only, so need to 'turn off' the old one.   What do i do?

    Hello shiv99,
    Welcome to the Apple Support Communities!
    I understand that you have used Home Sharing to play the music from one computer on another, but now you would like to only use the new computer. It sounds as though you have set up the content to share between computers, but have not actually I’m ported the media from the old computer to the new one. I would suggest following the troubleshooting steps located in the attached article to import you music from the old computer to the new one. After that process is complete, you can turn off Home Sharing if you would like and the content will be in the iTunes library on your new computer.
    iTunes 12 for Mac: Use Home Sharing to import items from another iTunes library
    Have a great day,
    Joe

  • Old movie will not play in new shockwave player

    Hi, I have searched the forums, Adobe support and web in
    general for help on this, but to my surprise have not found
    anything. I created some Shockwave movies perhaps 5 years ago for
    science education and have not used Director since then. I just
    received a report that the movies are broken and will not play.
    This is happening on WinXP in IE and in Firefox with the latest
    Shockwave player installed, but the movies work fine on OSX 10.4.8
    in Safari and Firefox, also with the latest Shockwave player
    installed. I am not a Director developer anymore and do not own a
    current version of the program, I am primarily a scientist and
    educator. I'm hoping the problem is in the code that embeds the
    movie, and that the movies are still compatible with the new
    Shockwave player on Windows. Can anyone help out, please? One of
    the movies can be found at
    http://www.biochem.umass.edu/mydna/modules/sort.html

    p

  • How do I delete old Bex queries not used within 13 months?

    Hello all,
    I have a large number of Bex queries that are no longer used (3000 - three thousand).  I'd like to delete any query that has not been used in 13 months.
    Can someone provide some guidance?
    Also, is there anyway to archive old reports?
    Thank you.
    JIm

    Murali,
    The RSZCOMPDIR table contains this information - thank you.
    The only remaining challenges are:
    1) how do I interpret or convert the values in the LASTUSED field?  The numbers are of the magnitude of 20,060,601,210,130.
    2) Once I determine which queries were not used within the last 13 months, how do I delete them?  Is it as simple as writing a SQL statement against this table?
    Thanks you.

  • I can not use the new Itunes. I have managed to erase my shuffle and can not get any songs from my library onto my ipod shuffle now!!!!!! Tutorials do not help!!!!

    Ineed a manual to use the new Itunes. The simple easy to use version is gone. The new version is TOO complicated !!!!!!!

    Hello SandyGF
    I would check out the following article that will bring back the sidebar that will make iTunes a little more familiar and get you back on track with syncing your iPod Shuffle.
    iTunes 11: Frequently used features
    http://support.apple.com/kb/HT5649
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

Maybe you are looking for

  • Silver/Black BT vision box

    We've had our silver vision box for over 2 years now.  I was just wondering, what's the difference?  I noticed the buttons of the box infront is different to the black one though the remote is still the same just in different colour (I think).  Diffe

  • One WLC for Headquarter and Remote Site

    Hi I have a question about the WLC remote deployment. We have the following design at the moment: Headquarter - Network 192.168.49.0 /24 - WLC 4402 Version 4.2.61.0 -- 3 x LAP1252 -- Layer 3 LWAPP -- SSID wep -- SSID wpa - Windows PDC with Active Dir

  • How to Extract the data from Microsoft BI to SAP BI 7

    Dear All, We have a requirement to Extract the data from Microsoft BI to Sap BI 7. How can we achieve this?? Shall we use the DB connection for this?? If anyone knows about this please give me some suggestion. Thanks in advance Sathiya

  • Help with print to video

    have canon xl2, Mac os x 10, Fcp 5 and trying to print to video. there is no video only audio. We have done a trash of qt files and reinstalled, repaired disk permissions and rebooted and used firewire basic ntsc setting and enabled all frames for ex

  • Mapping Problem Please help me

    After deploying my Mapping script I get the following messages: PL-SQL: ORA-00942 Table or view doesn't exist. and consequently I can't deploy and run my script. Does anybody have any idea. I have installed the OWB runtime and repository properly. Re