Image scaling / memory 3 questions

I hate to post this because I am sure there are a million posts about this, but I am still having a problem and it is taking tooooo long and I just cant find the solution. I am trying to scale images down to thumbnails. The images are really large and are consuming too much memory. Is there a way to scale the images and only retain the scaled bytes in memory rather than all of the image data.
I am assuming this is still stored because my program runs out of memory after creating about 3 thumbnails of large images, but works fine for smaller ones. I am loading the images in a thread (one at a time).
2. I tried to use the AffineTransformationOP and my images came out blueish? Anyone know about that. Not a major concern
3. Is it possible just to store the graphics from an image and use that to paint the component and completely eliminate having the image left in memory? maybe..??
persistantGraphics = image.creategraphics();
persistantGraphics.drawImage(image,0,0,null);
image = null;
paintComponent(Graphics g){ g = persistantGraphics;}Here is my scaling code.
BufferedImage image = ImageIO.read(theFile);
public static BufferedImage percentScale(BufferedImage orig, double percent){
        if(orig == null){return null;}
        int transparent = orig.getColorModel().getTransparency();
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        BufferedImage image = gc.createCompatibleImage((int)(orig.getWidth() * percent), (int)(orig.getHeight() * percent), transparent);
        Graphics2D g = image.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        AffineTransform xform = AffineTransform.getScaleInstance(percent, percent);
        g.drawRenderedImage(orig, xform);
        g.dispose();
        orig.flush();
        return image;
    }//end percentScale

Image#getScaledInstance()

Similar Messages

  • VI Method "Front Panel:Get Image Scaled" Memory Error 17

    Hi all, I've got two almost identical sub vi front panels that I'm dumping to a jpg image for reporting purposes.  One was copied and slightly modified from the other to show a different data set and plot.  The original works just fine, but the second sub vi, when using the "Front Panel:Get Image Scaled" method to pass the image to write the jpg, always returns the following error:
    "Error 17 occurred at Invoke Node in Myprogram
    Possible reason(s):
    LabVIEW:  Not enough memory to manipulate image.
    =============================
    NI-488:  Unrecognized command.
    Method Name: Front Panel:Get Image Scaled
    [Continue] [Stop]  "
    I've stripped the problem section into a simple tiny new that only opens the report and tries to get the image with the same working/non-working result above.  Using the Execution Trace Highlighter, it error is definitely occuring when the Method executes.
    Any ideas?  Thanks.

    Hey cjgpr,
        I haven't been able to dig up much info on this error message.  There's one other discussion forum post that talked about it some, and a KnowledgeBase article on it.  It seems that whatever changes you made to the front panel have caused it to exceed your computer's memory when creating an image.  Try removing items until it works, then see what actually breaks the functionality.
    Brian B
    Field Sales Engineer
    Tennessee/Southern Kentucky
    National Instruments

  • Problems with image scaling

    I'm facing a real problem with image scaling
    I've used several algorithms but it all has defects but the most common thing is the out of memory error after several enlargments...
    does any one know a solution...
    note:
    I've used several packages to do so,but I'm looking for a solution from the jdk itself
    JAlexscorpio

    Did you take into account that the getScaledInstance() -method creates a completly new Image?
    So if you use it like in
    ImageIcon icon1=new ImageIcon("Blah.gif");
    ImageIcon icon2=new ImageIcon(icon1.getImage().getScaledInstance(400,400,SCALE_FAST);
    you will end up with 2 different Images which have their own data and memory requirements.
    even if you use something like
    ImageIcon icon1=new ImageIcon("Blah.gif");
    Image i=icon1.getImage();
    icon1.setImage(i.getScaledInstance(200,200,SCALE_FAST));
    You will need enough memory to store the data for the original image, as well as the data for the scaled
    version of the image, at least for the time that it take the JRE to create the scaled version. You never know when the garbage collector kicks in to delete you old data so it could be that this takes some time and until
    that moment your memory is not available. If your now doing several of the scaling operations, and there is no chance for the garbage collector to do its work, you will run out of memory.
    I hope that might help, if not feel free to post again

  • ComboBoxRenderer with image scaling

    hi all,
    I would like to know how to make the comboBoxRender with image scaling. Because my combo box is smaller than the image that I want to put inside..
    currently, I "extends JLabel implements ListCellRenderer", but if I call setIcon to the Label, it is not scale to the combo size..., so I think is it need to extends another type of component ?
    Could some of you give me a suggestion , better provide me a simple code.. Many Thanks for help.

    Hi,
    I've extended the Icon framework to support scaling. I never tried it with cell renderers, but maybe it works:
    Extend JXIconLabel, set the zoomingStrategy to FullZooming.RESPECTING_ASPECT_RATIO_INSTANCE and set the XIcon (eg. a XImageIcon).
    Maybe it works. (The library is open source.)
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JXIconLabel.html
    Homepage:
    http://www.softsmithy.org
    Download:
    http://sourceforge.net/project/showfiles.php?group_id=64833
    Source:
    http://sourceforge.net/svn/?group_id=64833
    http://softsmithy.svn.sourceforge.net/viewvc/softsmithy/trunk/lib/src/org/softsmithy/lib/
    API:
    http://softsmithy.sourceforge.net/lib/docs/api/index.html
    If you have questions just ask me!
    -Puce

  • Image Scaling Percentage

    I am converting from Quark 6.0 to Indesign CS3 and have a comparison question.
    When viewing an image within Quark you can get specifics about the images scaling percent ratio. IE: 100%, Reduced would be obviously 99.99% to 10% or enlarged would be obviously 100.1% to 150%.
    Is there anyway to see that kind of percentage in InDesign. We try to stay under 150% and above 10% for our printer specifications, so it will make things very difficult if we can not view that info like in Quark.
    Any help is greatly appreciated!!

    I guess what I was hoping for is for the % to actually give its configuration from the original 100% instead of saying that it 100% after it has been reduced or enlarged. Between the info and the % it more or less makes sense, but it is not exact and I guess the user has to somewhat guess? Seems like more work for the user.
    Thanks for your help!!

  • Image scaling changes

    Before I started here, the team was using FrameMaker 8 and migrating to FM 10. During the migration, we noticed that images in the documents we opened, converting them to FM10, had their image scaling data changed.
    Typically, we acquire screen shots using the highest resolution screen supported - mine is currently set at 1440 x 900. We scale the images to a width of 510 pixels (optimally) but no more than 600 pixels in our screen capture utility. We save the screen shots as Grayscale JPEGs. This process has, historically, provided images that fit our text column flow perfectly.
    In previous versions of FM, the images imported by reference appeared as 100% scaling in the FM image properties. Now, they appear as 75% scaling. We're wondering why and if there is any effects we need to be aware of in terms of PDF and HTML Help file sizes.
    While testing the import process, looking to see if the FM scaling data affected the image size, we saw that the pixel dimensions given by SnagIt varied wildly from the pixel dimensions given by FM. For example, the SnagIt dimensions for one image indicated it was 505x493 pixels whereas FM gave the dimensions of the source file as 507x315 pixels. Both are, as far as I know, giving me the source file dimensions but they are different.
    We might not have noticed this, the images looked okay, but we were carefully going through the transition to FM10 and looking at every detail.
    Question: why is FM10 auto-scaling the images to 75%?
    Question: does this scaling do anything to our output that we need to be aware of?
    Question: why do we get two different dimension data from the two software packages?
    Thanks,
    Wanda

    We  save the screen shots as Grayscale JPEGs.
    Are the screen images contone (e.g. real-world photos, CGI imagery),
    or flat (e.g. dialogs, line art)? JPEG uses curve-matching compression,
    which is great for tones that vary smoothly, but introduces nasty ringing
    edge artifacts on sharp edges of flat tones.
    TIF(zip), uses repeat-count compression, and is both non-destructive to flat
    tone images, and often compresses them more efficiently. We use EPS
    for the import format (no compression) and let Distiller or Acrobat post
    determine the compression to use.
    This process has,  historically, provided images that fit our text column
    flow perfectly.In  previous versions of FM, ...
    What is the target delivery format?
    ... the images imported by reference appeared as  100% scaling in
    the FM image properties. Now, they appear as 75%  scaling.
    In case you want to try it, I have never seen imported EPS objects
    change size when migrating a document to a later rev of FM.
    We import using 96 dpi.
    If the target is PC screen display at 100% page size, that's probably a
    decent target. PC screen resolutions today probably range from 80 to
    110 dpi, and I'd guess that 96 is very close to the sweet spot.
    We use (and I favor) bringing in all contone content at 200 dpi or
    higher. We bring bitmap (bi-level line art) in at 600. But then our
    target media is 600 dpi B&W bitmap on paper. However, we like
    to give web readers of the PDFs reasonable detail in images.
    Apple's "Retina" crusade is trying to move the industry to 300 dpi
    displays. I'd be happy with 200.

  • Jmagick produce image in memory??

    Hi friends,
    I want to produce image via jmagick. But I don't want to produce a real file. So I produce image which save in the memory. When jmagick process completely, image will transfer to client.
    I wrote sample code, as follows:
    ImageInfo info;
    MagickImage image;
    MagickImage scaled;
    try{
    System.setProperty("jmagick.systemclassloader","no");
    info = new ImageInfo(request.getRealPath("/")+"Image/"+filename);
    image = new MagickImage(info);
    image = image.cropImage(new Rectangle(0,0,100,100));
    scaled = image.scaleImage(200,200);     
    byte data[]=scaled.imageToBlob(new ImageInfo());
    response.setContentType( "image/jpeg");
    OutputStream toClient=response.getOutputStream();
    toClient.write(data);
    toClient.close();
         }  catch(MagickApiException ex) {
                      System.out.println(ex);
         }  catch(MagickException ex) {
                System.out.println(ex);
         }  finally{//release memory
                  info=null;
                   image=null;
                   scaled=null;
                   System.gc();
          }But I found......
    When many people connect to this webpage, my memoey will increase very fast. And jmagick will not produce image. I don't know how to solve this problem.
    Please Help me...
    Thank you very much..
    Regards,

    If you create a lot of images in memory then that will take memory. So memory will go up.
    I have no idea what ou mean when you say the image isn't produced. Do you mean never? Then there is something wrong with your code here or you are not returning the correct thing to the clients.

  • I want to check all functions of PCI 6534.I have read the user manual..I have some memory related questions.​Please help me for that.

    I want to check all functions of PCI 6534.I have read the user manual..I have some memory related questions.Please help me for that.
    1.)If i am using the continuous output mode.and the size of generated data is less than 32 MB.If i want to preload the memory,what should i do?I want that first of all i load all my data to onboard memory & then i want to make start the transfer between 6534 & peripheral.Is it possible?As per me it should be.Plz tell me how should i do this?I think that in normal procedure the transfer between 6534-peripheral & outputting data from pc buffer to onboard memory works parallely.But i don't want this.Is it poss
    ible?
    (2).Similarly in finite input operation(pattern I/O) is it possible to preload the memory and then i read it?Because i think that the PC memory will be loaded automatically when 6534 acquires the data and then when we use DIO read vi the pc buffer data will be transferred to application buffer.If this is true,i do not want this.Is it possible?
    (3) One more question is there if i am using normal operation onboard memory will be used bydefault right?Now if i want to use DMA and if i have data of 512 bytes to acquire.How will it work and how should i do it?Please tell me the sequence of operations.As per my knowledge in normal DMA operation we have 32 Bytes FIFO is there so after acquisition of 32 bytes only i can read it.How it will known to me that 32 bytes acquisition is complete?Next,If i want to acquire each byte separately using DMA interrupts what should i do?Provide me the name of sourse from which i can get details about onboard memory & DMA process of 6534 specifically
    (4).In 6534 pattern Input mode,if i want to but only 10 bits of data.and i don't want to waste any data line what should i do?

    Hi Vishal,
    I'll try to answer your questions as best I can.
    1) It is definitely possible to preload data to the 32MB memory (per group) and start the acquisition after you have preloaded the memory. There are example programs on ni.com/support under Example Code for pattern generation and the 6534 that demonstrate which functions to use for this. Also, if your PC memory buffer is less than 32MB, it will automatically be loaded to the card. If you are in continuous mode however, you can choose to loop using the on-board memory or you can constantly be reading the PC memory buffer as you update it with your application environment.
    2) Yes, your data will automatically be loaded into the card's onboard memory. It will however be transferred as quickly as possible to the DMA FIFO on the card and then transferred to the PC memory buffer through DMA. It is not going to wait until the whole onboard memory is filled before it transfers. It will transfer throughout the acquisition process.
    3) Vishal, searching the example programs will give you many of the details of programming this type of application. I don't know you application software so I can't give you the exact functions but it is easiest to look at the examples on the net (or the shipping examples with your software). Now if you are acquiring 512 bytes of data, you will start to fill your onboard memory and at the same time, data will be sent to the DMA FIFO. When the FIFO is ready to send data to the PC memory buffer, it will (the exact algorithm is dependent on many things regarding how large the DMA packet is etc.).
    4) If I understand you correctly, you want to know if you waste the other 6 bits if you only need to acquire on 10 lines. The answer to this is Yes. Although you are only acquiring 10 bits, it is acquired as a complete word (16bits) and packed and sent using DMA. You application software (NI-DAQ driver) will filter out the last 6 bits of non-data.
    Hope that answers your questions. Once again, the example code on the NI site is a great place to start this type of project. Have a good day.
    Ron

  • Just bought a 2tb external hard drive with the intention of moving my iPhoto data files on it. I have so much of my 500 gigs being used up by images and video. Questions: Will this foul up my iPhoto app? Do I need to point iPhoto to this new location?

    Just bought a 2tb external hard drive with the intention of moving my iPhoto data files to it. I have so much of my 500 gigs being used up by images and video. Questions: Will this foul up my iPhoto app?
    Do I need to point iPhoto to this new location?
    Thanks!

    Are you running a Managed or a Referenced Library?
    A Managed Library, is the default setting, and iPhoto copies files into the iPhoto Library when Importing. The files are then stored in the Library package
    A Referenced Library is when iPhoto is NOT copying the files into the iPhoto Library when importing because you made a change at iPhoto -> Preferences -> Advanced. (You unchecked the option to copy files into the Library on import) The files are then stored where ever you put them and not in the Library package. In this scenario you are responsible for the File Management.
    Assuming a Managed Library:
    Make sure the drive is formatted Mac OS Extended (Journaled)
    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    Regards
    TD

  • Inserted memory card to upload photos to iPhoto and received this message "no images on memory card meet download conditions".

    I've been using my memory card from my Canon camera to upload photos to iPhoto.  No problem.  I attempted to use my daughter's memory card from her Canon camera (different model) and I get a pop up window stating "No images on memory card meet the download conditions."  Can anyone tell me why or what I can do so I can save these photos to my iPhoto?

    Well still the best guess is
    the best guess is incorrect settings (as far as Mac iPhoto is concerrened) on her Canon Camera
    Give image capture (in your application foder) a try and see what it sees
    Do yu have a card reader? If so try it and see what the finder sees on the card
    LN

  • Loading images into memory

    I have an applet that I need to load images into memory. For instance, lets say I am in the first section of the applet. While that section is being showed, I want to load the background image of the second section into memory.
    To load the initial image into momory, I am just using a Mediatracker. No problem there. But I don't want to load all 20 backgrounds into memory at the same time as they take a lot of time. My understanding is that if I create a new MediaTracker while the first chapter is running, it will potentially cause some chaos, as that will stop my thread from running while I have an image loading.
    Somebody told me perhaps I could create a new thread and have that thread load the backgroudn into momory? Perhaps something like this?
    public class TestClass extends JApplet {
         private TestClass thisClass;
         public void init() {
              thisClass = this;
              Runnable r = new Runnable() {
                   public void run() {
                        MediaTracker tracker = new MediaTracker(thisClass);
                        Image nextImage = getImage( getDocumentBase(), getImagePath() +"img1.jpg");
                        tracker.addImage(nextImage,0);
                        try {
                             tracker.waitForID(0);
                        } catch (InterruptedException ie) {
                             System.out.println(ie.toString());
              Thread t = new Thread(r);
              t.setDaemon(false);
              t.start();
              while(t.isAlive()) {
                   int i = 1;     
              t.stop();
              t.destroy();
    }No idea if I am on the right track or not? Another friend told me something about swing helpers but couldn't tell me much more?
    Thanks in advance!

    I use media tracker when I need information about how percent the image is loaded. you can use JLabel to load the images since it has own image observer in it.
    hope you just want to deal with it. easiest way I can offer :)

  • How can I load pattern matching images into memory?

    I discovered this problem by accident when our network went down. I could not run my VI because the .png file used for pattern matching was on a network drive. My concern it the amount of time that is required to read a network file. Is there a way to load the file into memory when the VI is opened?

    Brian,
    Thank you for contacting National Instruments. For most pattern matching programs, the pattern file should only be read from file once and is then copy to a buffer on the local machine. If you examine your code, or an example program for pattern matching, you should see at least two IMAQ Create VI called somewhere near the front of your code. This VI basically creates a memory location and most likely will be called once for your pattern image and once for the image you are searching.
    Unless you are specifically calling a File Dialog VI where you are given a dialog box to open a file or have hard coded the file path so that it is read each iteration of your code, then your pattern file should only need to be called at the beginning of your application, th
    us causing only one file read over the network for that image. Therefore your program most likely already loads the image in memory once it is read and should not be accessing the network constantly.
    Again, I would recommend taking a look at your code to make sure you are not causing a file access every time and then you should be ready to go. Just in case you do have the network go down, I would recommend keeping a copy of the image locally and, if you are feeling ambitious, you can programmatically have your program read the file locally if the network file returns an error.
    Good luck with your application and let us know if we can be of any further assistance.
    Regards,
    Michael
    Applications Engineer
    National Instruments

  • s:BitmapImage get image scaled size and position after it loaded and scaled

    I am try to know the dimensions of the uploaded image into <s:BitmapImage without success.
    The data coming back to me are isthe real image size and not size after it was scaled to fit the component size.
    I can see that the image scaled down and fit to the maxWidth, but I can't get the actual/real scaled width from the BitmapIMage properties.
    I tried:
    <s:BitmapImage id="mainBitMap"  ready="mainBitMap_readyHandler(event)" complete="bitmapimage1_completeHandler(event)" source="{data.Thumbnail.URL}" maxHeight="250" maxWidth="250" scaleMode="letterbox"/>
      protected function bitmapimage1_completeHandler(event:Event):void{ 
    trace("----------------------Start-----------------------"); 
    trace("mainBitMap.bitmapData.width" + mainBitMap.bitmapData.width); 
    trace("mainBitMap.width" + mainBitMap.width); 
    trace("mainBitMap.measuredWidth" + mainBitMap.measuredWidth); 
    trace("mainBitMap.displayObject.width" + mainBitMap.displayObject.width); 
    trace("mainBitMap.explicitWidth.width" + mainBitMap.explicitWidth); 
    trace("mainBitMap.preliminaryWidth" + mainBitMap.preliminaryWidth); 
    trace("mainBitMap.sourceWidth" + mainBitMap.sourceWidth); 
    trace("-----------------------End------------------------");
    Result:
    ----------------------Start-----------------------
    mainBitMap.bitmapData.width=435
    mainBitMap.width=0
    mainBitMap.measuredWidth=0
    mainBitMap.displayObject.width=0
    mainBitMap.explicitWidth.width=NaN
    mainBitMap.preliminaryWidth=NaN
    mainBitMap.displayObject.preliminaryWidth=435
    -----------------------End------------------------
    Thanks,
    Nimrod.

    Hi,
    I tried the ready event, But I still receive the same results.
    I expect to get the new scaled width And height according to the maxHeight and MaxWidth.
    I see that the image scaled to fi it But I can't recive the new size of it.
    Thanks,
    Nimrod

  • Firefox 27 memory leak (/questions/978195)

    I already did this, sorry , but now I include the automated information.....
    More than 6GB in 3 hours (MacOSX 10.7.5, 16Gb RAM)
    (No time personally to look at this but, I have tagged it as escalate)

    I will make a quick comment, but am unlikely to get back to this again before the weekend.
    First do not think we are ignoring this or saying it is not a problem. It is a case of it is something often difficult to pin down and must initially be checked and compared with Firefox in a clean configuration, and using memory figures from the Firefox's reporter about:memory.
    If you can ramp up memory usage to 6GB in only 3 hours at least it should be relatively easy to demonstrate whether or not something prevents that from happening.
    As a test please
    *Make an new additional Firefox Profile,
    *Run Firefox in Firefox's safe mode
    *With all plugins disabled
    * Look at memory use by using ''about:memory''
    * Browse for a few hours, has the problem now disappeared ?
    Instructions and discussions about this can be seen in thread
    * ''Firefox 26 on OS X 10.9.1 still has huge memory usuage (leak) which leads to crash'' [/questions/981674]
    *Thread mentioned in tile is <br />''Firefox 25 still has memory leaks'' [/questions/978195]

  • Copying an Image in Memory

    hello,
    How to copy an image from memory so that it can be restored later.
    For example:
    private Image buffered_image, SavedImage;
    private Graphics gbuf;
    buffered_image = createImage(tWidth, tHeight);
    gbuf = buffered_image.getGraphics();
    How?
    //Want to copy buffered_image to SavedImage
    later restore SavedImage to buffered_image
    Thank you

    If you know the two LINES of code, please post it instead of sending me a URL. thank you

Maybe you are looking for

  • Problem Downloading Windows Support Software

    Hello, I opened up Boot Camp Assistant and tried to download the Windows Support Software, however, when I click Continue, I get a pop-up saying, "The start-up disk does not have enough space to be partitioned. You must have at least 10GB of free spa

  • MacBook Pro heats up that i can barely touch it.

    Hey, I have a 2010 MacBook Pro 2.53 GHz Intel Core 2 Duo 4GB Memory 1067 MHz DDR3 500GB. Since i downloaded and installed Mac OS X Lion my laptop gets very very hot and the fan sounds really loud and it really is weird because i didnt face this probl

  • Setup 10.3 portal to connect to 8.1 content repository

    Hello, I am wondering, can I use the existing 8.1 WLP content repository as a third-party content repository for 10.3 WLP Virtual Content Repository (VCR)? Do I have to create the SPI implementation on the 10.3 side in order to connect to the 8.1 WLP

  • Lost my internet connectivity in my HyperV machines when updating to Windows 10 Preview 10061

    Hi, Windows 10 TP forced me an update to 10061 and this update caused me to loose my internet connectivity in my HyperV machines. I was sharing my wireless connection with an internal Virtual Network Adpater. Right now I've tried everything. I mean r

  • Problem with JSF provided Validator

    Hi, I am running following code using Java Web Services Developers Pack 1.3. and it's giving me exception. Anybody has any insight to this problem? I appreciate your time and help. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html>