Fast Image - Slow Image

Hi
In my game I load a 2D landscape from a gif image. The image consists of mostly two colors. If I use this image in my game, the game runs fast. as it should.
But to make the graphics nicer, I have drawn a second, small image with lots of colors and details. The idea is to replace one of the colors in the image (the ground) with this image. This method do that:
     public static BufferedImage changeColor (Image image, Color fromColor, Image toImage) {
           BufferedImage ri = new BufferedImage (image.getWidth(null), image.getHeight(null),BufferedImage.TYPE_4BYTE_ABGR);
           BufferedImage bImage = new BufferedImage (toImage.getWidth(null), toImage.getHeight(null),BufferedImage.TYPE_4BYTE_ABGR);
           bImage.getGraphics().drawImage(toImage,0,0,null);
           if (toImage.getWidth(null)<2 || toImage.getHeight(null)<2) return null;
           Graphics g = ri.getGraphics();
           int fromRGB = fromColor.getRGB();
            g.drawImage (image, 0, 0, null);
           for (int a=0; a < image.getWidth(null); a++)
              for (int b=0; b < image.getHeight(null); b++)
                 if (ri.getRGB(a,b)==fromRGB) {
                      int x=a, y=b;
                      while (x<0 || x>=toImage.getWidth(null) || y <0 || y>= toImage.getHeight(null)) {
                           if (x<0) x+=toImage.getWidth(null);
                           if (x>=toImage.getWidth(null)) x-=toImage.getWidth(null);
                           if (y<0) y+=toImage.getHeight(null);
                           if (y>=toImage.getHeight(null)) y-=toImage.getHeight(null);
                        ri.setRGB(a,b,bImage.getRGB(x,y));
          return ri;
    }This method returns a BufferedImage. But when I use this BufferedImage in the game, the game becomes really slow.
So, I don't know why this happens. Is it always slower to draw an image whith many colors than an image with few colors? Or is BufferedImages always slower than images returned from Toolkit.getImage()? Or do I use the wrong type of BufferedImage?
cccB

new BufferedImage(....) are not managed (cached in vram)
Images loaded from toolkit.getImage() are managed.
Also, the color model BufferedImage.TYPE_4BYTE_ABGR is not an efficient colormodel.
It will require conversion to the displays colormodel (which is probably TYPE_INT_RGB/ARGB/BGR)
Change your BufferedImage creation so it uses graphicsConfiguration.createCompatibleImage(...)
The BufferedImage returned will be a colormodel compatible with the display, and will be managed (cachable in vram)

Similar Messages

  • Lightroom 15000+ images ; Slow

    Computer Specs: iMac 20" Intel Core 2 Duo with 2.16 GHz with 2GB Ram and 250 GB Harddrive.
    Problem #1 15000+ image slow ...
    ==========
    I'm using Lightroom since a month now, initially i downloaded the beta version and moved about 2000+ images (about 80% raw files, rest jpg) and it was working great ...
    Now I've just purchased Lightroom 1.0 and moved about about 5 years of my digital pictures about 15000+ pictures. First i imported the first set of 2000+ pictures and it worked great again ...
    then I imported 14000+ pictures (mostly jpg, less then 500 were raw) and the response from lightroom changed dramatically, it is slow. I want to assign my keywords to the pictures and tell remove the rejects and come down to 10000+ pictures. But this collection will grow,
    My question to you is ...
    1) Can ligthroom handle 15000+ pictures, if yes what i'm doing wrong ...
    Problem # 2 Backup ... Using Export ...
    ===========
    The way I'm backup is ... I select all pictures in the library (it was okay when manageing 2000+ pics) ... and export them to my external harddrive as DNG ... this converts my .NEF to .DNG which is perfect, but
    this one also convert all my .JPG to .DNG.
    Is there a way to convert only my .NEF TO .DNG but backing up my JPG as JPG
    Is there another way to backup, i could not find a menu entry to backup on Lightroom.
    Thanks in advance
    Sajid

    I have almost 13,000 images in my Library on a Windows system (Dual Core AMD 64 x2 - 2.2 Ghz - and 2 gb memory). I notice that LR takes much longer to open fully. If I wait for the HD to stop reading then LR responds fairly quickly. When scrolling through a lot of images I find that using minimal cells, instead of expanded, speeds up the thumbnail building issue. All in all I do find that LR gets pretty slow when well loaded with images, but that should improve with future upgrades.
    I do still wonder why LR needs to rebuild thumbnails every time it opens. Bridge CS3 takes longer to build thumbnails, but it only has to do it once so it is faster the next time you open that folder.

  • Slow image loading in Facebook and other sites.

    In some sites, especially Facebook, I've a slow image loading. For example, when I search for a person on Facebook, then the profile image of poeple takes 6-7 secons to load.
    I've installed Firefox yesterday, so I exclude that I have to delete cookies, etc. With Chrome, Facebook load images much more faster. Re-installing shockwave, the loading is faster, but not enough.
    Any suggestions?

    After looking around a bit, I found an add-on called FastestFox.
    You can find the add-on here: [https://addons.mozilla.org/nl/firefox/addon/fastestfox-browse-faster/ FastestFox].
    I haven't done too much research to the actual add-on itself, but after installing it in Firefox myself and using the Facebook person searcher I noticed the images and also other things like websites loading a lot faster.
    I hope this add-on helps you.
    Edit: The add-on adds some extra options when you right click a website (to download things from the website). You have to decide if you think this is worth the extra speed.

  • Extremely slow imaging on HP DC7700 with 2GB of RAM

    Hi
    Hope you can help. I've got a dozen new HP DC7700's that we are
    attempting to image with Zenworks 6.5 SP2 Hotpatch 4. We have about 20
    different types of workstation in this environment and all of these
    workstations image in approximately 6-8 minutes.
    When we first received the HP DC7700 I had to make some mods to our
    environment as discussed in the following topic ...
    http://groups.google.com.au/group/no...bac07299d56ecd
    .... and finally got the HP DC7700 (with 1GB of RAM) imaging (with
    exactly the same image and similar size driver package) in 15 minutes
    (i.e. about double our normal imaging time). Put that on the things to
    do list to find out why the imaging time doubled but we could live with
    that.
    Then the other day we got some HP DC7700's delivered with 4 x 512MB
    sticks of RAM and started the imaging process. Now it's ground to a
    halt. It's taking approximately 3 hours to image the workstation. So
    now I have to find a solution.
    I've tested to make sure it's not a problem with the additional 1GB of
    RAM by removing all the RAM and using the additional 1GB RAM as the
    only RAM in the workstation. The workstation imaged in about 15 mins as
    before. Put 2GB in the workstation and imaging slows down to a crawl
    again.
    Does anyone have any idea what is going wrong and where I should start
    to look to fix the problem?
    I am aware of the release of Zen 6.5 SP2 IR1 but would prefer not to
    upgrade at this stage as we've just got everything working so well here
    that I'd like to get some mileage out of it before upgrading and
    possibly introducing some new issues.
    Many thanks
    Craig

    On Sun, 10 Dec 2006 23:18:49 GMT, [email protected] wrote:
    > I am aware of the release of Zen 6.5 SP2 IR1 but would prefer not to
    > upgrade at this stage as we've just got everything working so well here
    > that I'd like to get some mileage out of it before upgrading and
    > possibly introducing some new issues.
    I guess trying that as fast as possible is your only chance.. there will
    only be ONE final patch for 6.5 and this is already in beta. If the problem
    is really the ram and it could be fixed easily you have a slight chance
    that this could move into the latest patch. Otherwise you will have to live
    with it if there is no other workaround
    If you have already compiled drivers or have linux.2 please put them on
    http://forge.novell.com/modules/xfmo...ect/?zfdimgdrv
    Live BootCd and USB Disk from Mike Charles
    http://forge.novell.com/modules/xfmod/project/?imagingx
    eZie http://forge.novell.com/modules/xfmod/project/?ezie
    Marcus Breiden
    If you are asked to email me information please change -- to - in my e-mail
    address.
    The content of this mail is my private and personal opinion.
    http://www.edu-magic.net

  • Very slow image operation

    Hello,
    I have a strange problem.
    Some of my images are VERY slow to load, scale... (any image operation).
    I have those 2 images :
    http://193.252.5.30/tmp/cat1.jpg (25Ko : 295x551 pixels)
    http://193.252.5.30/tmp/cat2.jpg (24Ko : 295x551 pixels)
    I wrote a little program which load and scale the image.
    Here is the result :
    cat1.jpg
    Time to load image : 171 ms.
    Time to scale image : 157 ms.
    cat2.jpg
    Time to load image : 1157 ms.
    Time to scale image : 2578 ms.How can this huge difference explained ?
    Thanks for your help.
    The program :
    public class Test
         private final static BufferedImage scale(BufferedImage source, float scaleFactor)
              int width = Math.round(source.getWidth()*scaleFactor);
              int height = Math.round(source.getHeight()*scaleFactor);
              ColorModel dstCM = source.getColorModel();
              BufferedImage dst = new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(width, height), dstCM.isAlphaPremultiplied(), null);
              Image scaledImage = source.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING);
              Graphics2D g = dst.createGraphics();
              g.drawImage(source, 0, 0, width, height, null);
              g.dispose();
              return dst;
         public static void main(String[] args) throws IOException
              String imagePath = "cat1.jpg";
              //String imagePath = "cat2.jpg";
              long t1 = System.currentTimeMillis();
              BufferedImage image = ImageIO.read(new File(imagePath));
              long t2 = System.currentTimeMillis();
              System.out.println("Time to load image : " + (t2-t1) + " ms.");
              t1 = System.currentTimeMillis();
              image = scale(image, 0.2f);
              t2 = System.currentTimeMillis();
              System.out.println("Time to scale image : " + (t2-t1) + " ms.");
    }

    Hello,
    I have a strange problem.
    Some of my images are VERY slow to load,
    scale... (any image operation).
    I have those 2 images :
    http://193.252.5.30/tmp/cat1.jpg (25Ko : 295x551
    pixels)
    http://193.252.5.30/tmp/cat2.jpg (24Ko : 295x551
    pixels)
    I wrote a little program which load and scale the
    image.
    Here is the result :
    cat1.jpg
    Time to load image : 171 ms.
    Time to scale image : 157 ms.
    cat2.jpg
    Time to load image : 1157 ms.
    Time to scale image : 2578 ms.How can this huge difference explained ?
    Thanks for your help.Using the Netbeans profiler, I can see that for some reason, the cat2.jpg image is resulting in a hot spot where the scale() method ends up performing a color conversion via ColorConvertOp. Placing a debugger breakpoint on this call and debugging the code using cat1.jpg, the method is never called. So, there is something different about the color models of the two images, or there is a bug in the image reading code that is misinterpreting the image data.
    This bug may be what you are seeing:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4705399

  • My airplay mirroring won't work with my macbook air, eventhoug my internet connection is very fast. The image will appear after 5 seconds.

    My airplay mirroring won't work with my macbook air, eventhoug my internet connection is very fast. The image will appear after 5 seconds.

    Mirroring is done over the local network so internet speed isn't relevant.
    I would check istumbler.net to see if there is any interference

  • Is there a way to keep the Brush HUD up as I move from image to image?

    I did a large set of portraits and would like to keep the Brush HUD up as I move from image to image making edits.
    Being able to do this would save a little time and make the edits a little faster.
    Thanks

    Not that I've found.  Some brush HUDs stay "up" when a different image is selected (crop, retouch), but most do not.
    I suggest assigning easy shortcuts to any of the Quick Brushes you use regularly, and launching them from the keyboard.
    This is also an instance where a multi-button programable mouse could pay for itself.  Assign those shortcuts to some of the mouse buttons.  (I use and recommend the Razer Naga; surely there are others, and newer ones.  The increased resolution alone is worth the price -- but all that is off topic.)

  • How to handle invalid images in "Image" report item?

    I have a report that displays images in Image item (MIMEType image/jpeg) in the table. Images are stored in the database.
    Some of the images are, however, not a valid jpeg files (not sure what they are but I saved them as files and they cannot be opened by any graphics editor). When report server tries to display such an image in the report whole report fails.
    Similarly, web application that tries to display them on the web page throws an exception. In web application we can catch that exception and show static "IMAGE IS INVALID" bitmap instead.
    Is there a way to handle/catch such errors in SSRS? The way it is now is not good because error message doesn't tell you anything specific about error.

    Enabling SSRS Remote errors
    http://technet.microsoft.com/en-us/library/aa337165.aspx
    http://www.sharepointjohn.com/sql-reporting-services-2008-r2-enable-remote-errors/
    Displaying custom error message
    http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/2b891541-836f-4d9d-89f3-d2340319f453/
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • mx:Image no image preview in Design Mode

    Inside my Flash Builder (4.01) AIR project, the image preview in design mode for the mx:Image component does not show the image set with the source attribute.
    This seems to be a project specific problem. When I create a new project , insert mx:image and set the source to an image, the image is previewed just fine. I also get a possible related error saying : "Design mode could not load swiz-framework-1.0.0-RC1.swc. It may be incompatible with this SDK, or invalid. (DesignAssetLoader.CompleteTimeout)"
    This error pops up in several google searches and is by some regarded as an sdk bug, so I dont know the relevance here.
    This happens in various flavours of the Flex SDK  (4.0/4.1 latest versions).
    Thanks in advance

    Ok, I found out it has definitively something to do with the "Design mode could not load swiz-framework-1.0.0-RC1.swc. It may be incompatible with this SDK, or invalid. (DesignAssetLoader.CompleteTimeout)" warning. This somehow affects the loading of the mx:Image.
    Recompiling the SWC might work with the swiz swc, but there are more swc's giving this error like the google maps swc which does not have the source avalable freely.
    This is a real pain as I like to use a mockup image in Design Mode to place components exactly as provided by the design team.

  • Images and image maps do not respond to events on Safari

    Hello everyone,
    We have been experiencing issues with events not responding to images associated with image maps, on Safari browser. After the DOM is loaded with new image and corresponding image maps, events such as mouseover and click observing this divs do not respond or get triggered. DOM seems to be updated correctly but behaves differently (and it works correctly in all other browsers except Safari).
    This behaviour is only noticed in Safari browser running both on Windows and Mac. (Tested on Safari Version 3.1.1 on running on Windows and Mac)
    For you all to have a closer look at this issue, I have created a sample that has this problem, similar to one we experienced during one of our recent projects. Please click on the link below to get to the sample (I recommend you to try this either in Firefox or IE before you do on Safari)
    http://www.hivegroup.com/safari/test.html
    (In the above sample,
    - the javascript code initializes the DOM with image and image map
    - assigns two event listeners to the div containing this image and image map
    - when mouse pointer brought over the image, it shows the area id in the 'mobox' div
    - when clicked, DOM is updated with a new image and new corresponding image map, assigns new event listeners and should continue with the same kinda behaviour it did for the first image (but doesn't in Safari browser))
    All inputs on this issue are welcome and greatly appreciated.
    Thanking you in advance.
    Regards,
    Shashi.

    Let me explain what the pink area is. Like the first image that contains two white boxes, the pink area (as you call it) is a new image (containing four pink areas or boxes having an area id denoted to each) that imgDiv occupies after the 'click' event occurs.
    Yep, i gathered that from seeing it work on firefox...
    The point that I'm trying to make here is, there shouldn't be any difference in behaviour when imgDiv holds first image (two white boxes) or the second image (four pink boxes) that you get after we click on image or the third image (containing 6 boxes, multiple colors) which you won't be able to reach in safari browser.
    well... I can reach them, but only via the blue space.
    . We'll notice change in the red box displaying target id only when we mouse over a new area that is not currently being displayed in the red box.
    except in webkit for safari 2, where thered bpx content sticks at whatever it was when the first image was clicked, unless mouse is moved to the 'all area', and then it sticks on imgdiv.
    I completely understand what you see in safari 2. But are you saying there's some error in my script ? If so could you please point out and justify.
    I dunno Shashi, just pointing out the errors that Safari 2 reports when I view your test page, in the hope it might help. I know little of javascript

  • How to fit to size to show the whole image in image display?

    HI, I am using a control palette to display my video images using image display. However, the size is alway out of proportion. How do i show the whole image in the small box screen size. Basically how to fit to size for the images? 
    Solved!
    Go to Solution.

    This should do the trick:
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Find raster Image & Vector image in adobe indesign using apple script?

    Find raster Image & Vector image in adobe indesign using apple script?

    Find raster Image & Vector image in adobe indesign using apple script?

  • Shared Components Images Create Image does not work

    I am using oracle XE on Windows XP.
    Uploading an image for an application does not work.
    Home>Application Builder>Application 105>Shared Components>Images>Create Image
    It goes wrong when I try to upload the image:
    - Iexplorer gives an error 404 after pressing the Upload button.
    - Firefox just gives an empty page.
    When I try to refresh the resulting page (do another post) I get the following error:
    Expecting p_company or wwv_flow_company cookie to contain security group id of application owner.
    Error ERR-7621 Could not determine workspace for application (:) on application accept.

    Hi Dietmar,
    After setting the language to English (USA) [en-us] it works for +- 50 % of the uploads.
    Below is my tracefile.
    Dump file e:\oraclexe\app\oracle\admin\xe\bdump\xe_s001_2340.trc
    Wed Nov 23 19:03:17 2005
    ORACLE V10.2.0.1.0 - Beta vsnsta=1
    vsnsql=14 vsnxtr=3
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Beta
    Windows XP Version V5.1 Service Pack 2
    CPU : 2 - type 586
    Process Affinity : 0x00000000
    Memory (Avail/Total): Ph:267M/1014M, Ph+PgF:1431M/2444M, VA:1578M/2047M
    Instance name: xe
    Redo thread mounted by this instance: 1
    Oracle process number: 15
    Windows thread id: 2340, image: ORACLE.EXE (S001)
    ------ cut ------
    *** 2005-11-23 19:50:44.718
    *** ACTION NAME:() 2005-11-23 19:50:44.718
    *** MODULE NAME:() 2005-11-23 19:50:44.718
    *** CLIENT ID:() 2005-11-23 19:50:44.718
    *** SESSION ID:(26.18) 2005-11-23 19:50:44.718
    Embedded PL/SQL Gateway: /htmldb/wwv_flow.accept HTTP-404 ORA-01846: not a valid day of the week
    *** SESSION ID:(27.19) 2005-11-23 19:50:51.937
    Embedded PL/SQL Gateway: /htmldb/wwv_flow.accept HTTP-404 ORA-01846: not a valid day of the week
    *** 2005-11-23 19:50:59.078
    *** SERVICE NAME:(SYS$USERS) 2005-11-23 19:50:59.078
    *** SESSION ID:(27.21) 2005-11-23 19:50:59.078
    Embedded PL/SQL Gateway: Unknown attribute 3
    Embedded PL/SQL Gateway: Unknown attribute 3
    Strange error... there is nothing in my form that is related to dates...
    Kind regards,
    Pieter

  • Images (and image folders) in the same folder as Lightroom Catalog?

    I'm just switching over from Aperture 3 to Lightroom 4.  I'm wondering if its ok (or smart) to keep the images (and image subfolders) in the same folder that the Lightroom.lrcat and Previews files are kept in.  I'm trying to better organize my Pictures folder so that there are a whole bunch of separate sub-folders.  Thoughts?

    In Lightroom, there is no specific location where the photos should go. You can put them wherever you want, based upon your storage needs and hard drive setup.
    So, with regards to your specific question, yes you can put the photos in the same folder as where the .lrcat is located, I can't see any harm, but I also don't think you need to do the work to make that happen. You can pretty much leave your photos where they are (which is easier and less time consuming) than moving them to the .lrcat folder, and easier and less time consuming than moving them at all.
    In fact, I strongly suggest you change your thought processes from "Where do I put my photos" to "How can I organize my photos". Now that you are a Lightroom user, you organize your photos from within Lightroom, not by moving them here to there, but by adding keywords and other metadata. Organizing, now that you are LR user, is not folders ... it is metadata. Searching, now that you are a LR user, is not done in your operating system and in folders, it is done in LR by searching for keywords and other metadata.

  • Excel Rendering Extension: Unknown Image Format Imag/GIF - SSRS Excel Export

    We are using the SSRS 2012 [ExportOpenXML].
    When a report is export to excel, getting the message Unknow Image Format IMage/GIF.
    Please suggest a fix the above issue.
    As per article Excel Rendering extension: Unknow Image Format image/x-png suggestion verified in Visual studio selected the gif file in the Solution Explorer panel, checked the Properties
    the MIME Type which is already set as image/gif.
    Note: Dev environment its working as expected and but issue is observed in QA environment. I wonder some setting is missing on QA enviornment which I'm unable to get the difference exactly.
    Quick help would be higly appreciated.

    Hi Niranjan,
    Based on the current description, I understand that there should be no issue when exporting the report containing image which is Image/Gif type in Dev environment because you have changed the MIME type to Image/Gif.
    To narrow down the scope to find the cause, I want to confirm some information below:
    1. Check Reporting Services edition in QA environment, if the Reporting Services edition is same between QA and Dev environment, you can back up the .rdl file and copy the .rdl file to QA environment and then export the report in Excel format to check
    whether the issue persists.
    2. If you export the report to other format such as PDF rather than Excel format in QA environment, please confirm whether the issue persists.
    3. If you change the MIME type to Image/Png and then export the report to Excel in Dev and QA environment, please confirm whether the issue persists.
    Supposing there is error message, please post the details to the forum for further analysis.
    Reference:
    How do you check what version of SQL Server for a database using TSQL?
    Regards,
    Heidi Duan
    Heidi Duan
    TechNet Community Support

Maybe you are looking for