Image Backgrounds - .gif

Hi. Im making an rpg, and while trying to add the image of the person ontop, i noticed that, unlike on websites, the background of black isnt transparent. Could someone please help. Is there a color that java reconizes as see-through for a .gif?
Thanx in advanced,
ME :D

Would a png reduce the time it takes to repaint?
Not per se, no. Images are decoded when loaded so the source is pretty much irrelevant.
My brother said being able to look at the hex value and not the .grabPixels() array would reduce the time it take to repaint. Is this true?
I'm not sure I follow. What are you doing? You don't need to grab pixels to repaint, are you manipulating the image directly in between paint cycles? If so then you can expect operations to be quite slow.
4000 x 3500 image cut in 2. Would that reduce repaint time?
Possibly. Are you using transforms to render with? If not then you can't hope to render all that on a screen so there'd probably be no harm in tiling it.
Right now what is happening is u can see each picture repaint itself.
I suspect what you have, since you're using GIFs (which are palletised) is an image which has a data transfer type different to that used by the graphics device.
Via GraphicsEnvironment and GraphicsDevice you can get GraphicsConfiguration and query its ColorModel and then its transfer type. In most cases this will be an integer type but it's best to check.
Then, from the BufferedImage you've created, get its ColorModel and the transfer type. You'll probably find with a GIF-sourced image that it's a byte type.
If the two transfer types are different then pasting the image is a costly operation: what you need to do is use the GraphicsContext to create a compatible image, then render your old image into it, and dispose of the old one.
That's a fairly undesirable step to have to go through - it'll obviosusly take a bit of processor time for an image the size of yours and there's the memory overhead of having it in memory twice as well (even though the initial image will be only a quarter the size of the compatible one, if it uses bytes instead of ints). So one thing you can do is store your image as a true-color PNG instead of a GIF - there's nothing magic about this, but what it does mean is that on decoding it you will end up with a color model and transfer type which is integer-based and will render quickly for anyone using a true-color display (which is most people).
You're doing this in an applet and an integer-based image of that size is going to cause you massive problems with heap space. You've got 96Mb to play with and that image will eat 56Mb of it. If you're having to copy a byte image to it then that's going to require an extra 14Mb overhead.
I would strongly question the wisdom of using a 4000x3500 image in an applet. What are you using it for? Can you find an alternative means of rendering the image or parts of it? - eg if a lot of it is plain-colour then can you break it into parts which only cover the non-plain sections? if there are repetitions in the image can you re-use tiles?
Oh hang on, it'd help if I checked that applet link...
WHOA! Yeah - there's no need at all for a huge image like that! You only have two background tiles, a green one and a blue one - use a data structure to lay out the tiles, eg if you wanted four green squares surrounded by a ring of blue squares you might do it like this,
int[][] map =
    { 0, 0, 0, 0 },
    { 0, 1, 1, 0 },
    { 0, 1, 1, 0 },
    { 0, 0, 0, 0 }
}...though you'd be better off sticking the values in a text file and parsing it to create the map.
Hope that all helps.

Similar Messages

  • Loading transparent background gif on an image

    Hello everyone! I am trying to load a transparent background gif([http://www.aoml.noaa.gov/hrd/tcfaq/graphics/animehurr.gif]) on another image (which is a map). My way is adding two JPanels, each of them will load an image as an ImageIcon, however, the gif will display its transparent background as white. So, I googled the problem, it seems someone has a similar problem([t-681840]). I think the background area is not transparent due to the wrong container under the image, but I have no clue to make it right. I appeciated anyone can post a comment, or give me some advice.
    I attach my code as following.
        jPanel1 = new JPanel();
        getContentPane().add(jPanel1);
        jPanel1.setBounds(12, 10, 647, 358);
        ImageIcon iconMap = new ImageIcon("C:\\1\\com\\lfhsolutions\\trackthis\\images\\Map.JPG"); 
        JLabel label1 = new JLabel(); 
        label1.setIcon(iconMap);  
        jPanel1.add(label1);  
        this.getContentPane().add(jPanel1);
        setVisible(true);
        jPanel2 = new JPanel();
        getContentPane().add(jPanel2);
        jPanel2.setBounds(330, 200, 50, 46);
        ImageIcon iconHurricane = new ImageIcon("C:\\1\\com\\lfhsolutions\\trackthis\\images\\hurricane1.gif");
        JLabel label2 = new JLabel();
        label2.setIcon(iconHurricane);
        jPanel2.add(label2);
        this.getContentPane().add(jPanel2);
        setVisible(true);

    Sorry if my code bothers u, camickr !
    I am a noob for java and thie forum. I am not quite sure how a SSCCE should look at, but I will post code as below.
    import java.awt.BorderLayout;
    import java.awt.Canvas;
    import java.awt.Image;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.List;
    import javax.swing.GroupLayout;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JLabel;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.LayoutStyle;
    import javax.swing.WindowConstants;
    import javax.swing.SwingUtilities;
    public class NewJFrame1 extends javax.swing.JFrame {
      //Set Look & Feel
      try {
       javax.swing.UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
      } catch(Exception e) {
       e.printStackTrace();
    private JPanel jPanel2;
    private JPanel jPanel1;
    * Auto-generated main method to display this JFrame
    public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
       public void run() {
        NewJFrame1 inst = new NewJFrame1();
        inst.setLocationRelativeTo(null);
        inst.setVisible(true);
    public NewJFrame1() {
      super("Hurricane Tracker to Oil and Gas Producers");
      initGUI();
    private void initGUI() {
      try {
       setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
       getContentPane().setLayout(null);
        jPanel1 = new JPanel();
        getContentPane().add(jPanel1);
        jPanel1.setBounds(12, 10, 647, 358);
        ImageIcon iconMap = new ImageIcon("C:\\1\\com\\lfhsolutions\\trackthis\\images\\Map.JPG"); 
        JLabel label1 = new JLabel(); 
        label1.setIcon(iconMap);  
        jPanel1.add(label1);  
        this.getContentPane().add(jPanel1);
        setVisible(true);
        jPanel2 = new JPanel();
        getContentPane().add(jPanel2);
        jPanel2.setBounds(330, 200, 50, 46);
        ImageIcon iconHurricane = new ImageIcon("C:\\1\\com\\lfhsolutions\\trackthis\\images\\hurricane1.gif");
        JLabel label2 = new JLabel();
        label2.setIcon(iconHurricane);
        jPanel2.add(label2);
        this.getContentPane().add(jPanel2);
        setVisible(true);
       pack();
       this.setSize(806, 549);
      } catch (Exception e) {
       e.printStackTrace();
    }}

  • Background gifs

    Is it possible to import and tile a background gif into a pages document? I'm trying to create a page I can email that has a tiled background, where the background is taken from a site that offers free backgrounds. I like the background in iWeb that looks like black cloth. Would like to use that background in a Pages document. Can this be done? Thanks for any help.
    donald

    We can't insert a Pages document in a mail.
    We may only attach it and this requires a complementary task: pack the doc as an archive (zip for instance).
    Pages documents requires Pages to read them.
    Given that, as the Users guide claims:
    Working with Images
    +Pages accepts all QuickTime-supported formats, including the following graphics file+
    types:
    +• TIFF+
    +• GIF+
    +• JPEG+
    +• PDF+
    +• PSD+
    +• EPS+
    +• PICT+
    I checked that we really may insert GIF objects and move them to background.
    Yvan KOENIG (from FRANCE mercredi 30 juillet 2008 11:13:05)

  • Region Image Background

    Hello,
    Does anybody know how to set up a image background on a region.
    I want to have different backgrounds for my two different regions.
    Can someone help me.
    I tried with the background style but it end up putting the background on the outer region (the main one) so I'm not sure how to do this.
    Sorry to bother you if this is very easy to do, but right now I don't have an idea on how to do it.
    Regards,
    Ruben

    Hi,
    Add to Region "Region Attributes" something like
    style="background: url(#WORKSPACE_IMAGES#mypic.gif)"Replace #WORKSPACE_IMAGES#mypic.gif with url where is your image you like use as background
    Br,Jari

  • File does not exist: /export/home/oracle/orahtml/marvel/images/spacer.gif

    Seeing this error in the apache log:
    File does not exist: /export/home/oracle/orahtml/marvel/images/spacer.gif
    I know there are spacer.gif files under the theme folders but why is it looking for a spacer.gif file in the images folder? Is this a bug?

    Hello,
    Yes I just checked it's a problem with theme 9 there are a couple of places where the theme calls #IMAGE_PREFIX#spacer.gif when it should call #IMAGE_PREFIX#themes/theme_9/spacer.gif
    There are two ways for you to fix this
    1. Copy themes/theme_9/spacer.gif to the top level images directory, I recommend this one because then if someone creates the theme from the repository again it wont' come up agian.
    2. Change all #IMAGE_PREFIX#spacer.gif to #IMAGE_PREFIX#themes/theme_9/spacer.gif in theme 9, if you export the theme you can just us a search and replace the export to do this and then reapply the theme.
    This as been bugged and will get fixed in future version.
    Carl

  • How can i convert an image into gif file as jpeg by using com.sun.image.*

    please help me to convert an image into gif format. i have used sun's impl com.sun.image.code.jpeg package to convert a buffered image into a jpeg file. is there any implementatioln available from sun to handle gif files.

    Many. Try for instance google with 'java image encoders'. Go to the URL http://www.google.com/search?q=java+image+encoders and be amazed of the wonders of modern web search tools.

  • How to show an image(jpg/gif) on a JTabbedPanel

    Hi
    I tried to show an image on a JPanel of a JTabbedPanel.
    I the only way to show it for some time was this:
    in the StateChangedListener I use drawImage when the selected panel is teh one I want to draw the image at.
    Tracing code makes the panel show, burt when I step
    all the way up, the panel will be repainted without my image.
    I use mediatracker to get the image loaded.
    Any Idea
    Hanns

    JTabbedPane has components as its tabs. Using a JPanel is not mandatory. Try using a JLabel instead with an Icon (use ImageIcon) in it.
    JTabbedPane tabbed = new JTabbedPane();
    tabbed.addTab(
        "my image panel",
        new JLabel( new ImageIcon( "images/MyIcon.gif" ) )
    );if your were referring to the image of the little tabs, use this:
    JTabbedPane tabbed = new JTabbedPane();
    tabbed.addTab(
        "my tab",
        new ImageIcon( "images/MyImage.gif" ),
        myPanel // instance of Component, can be a JPanel or any JComponent you want.
    );

  • How to make a Transparence Background GIF Animated??

    Hi,
    How to make a Transparence Background GIF Animated??
    Any Special Pro software do i need like Photoshop ?
    Posible to use Keynote or something like that?
    Thanks

    See my response to your other topic in this forum.
    OT

  • How can I remove an image background in pages?

    I want to know how to remove image backgrounds just like how you do so through "instant alpha" on a mac.

    Hi Erika,
    Are you trying to save a portion of an image with a transparent background? It may help to post a screenshot of the image that you're working with as well as your layers panel.
    I've included a few tips below that may help you with your situation. If you need additional help, please feel free to post again
    Deleting a background and saving an image with a transparent background
    1. Here I am working with an image of a santa hat that I've cut out from a white background. I have two layers, the cut-out santa hat and the original file. I'm going to delete the background layer so that I have just one layer - the cut-out santa hat:
    2. You'll see that a checkerboard pattern has appeared behind the santa hat. This means that the background is transparent.
    3. You can then go to File > Save As... and select PNG, Photoshop PSD, or TIFF from the Format dropdown menu. These file formats will save the cut-out portion of your image on its own, while preserving the transparent background.

  • Loading Images jpg, gif, png

    What is the most effective way to load an image in my application?
    Bellow is how i am currently loading the image:
    private void drawMap() {
    Graphics g = this.picturePanel.getGraphics();
    Image img = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/claymonmap.gif"));
    g.drawImage(img,0,0,this);
    This method works however it takes sometime for the image to show. The method is called from a button action, and the image wont display unless I have pressed the button alteast two times. I do not need to do an manipulation to the image simply display it.
    I was hopeing for a more instantaneous result.
    Your input would be greatly appreciated.

    I changed to using imageicon and i found that its is much quicker thanks.
    however i am having troubles with the method bellow. When i click a certain button the focus on a tabbed pane goes to buildingPicturePanel, and the picture flashes up for a microsecond and then the panel goes blank again. The picture wont show till i click the button again.
    void getBuildingPic(String id) {
    Graphics gBuilding = this.buildingPicturePanel.getGraphics();
    ClassLoader cldr = this.getClass().getClassLoader();
    String pathBuildPic = "images/"+ id +".jpg";
    java.net.URL imageURL = cldr.getResource(pathBuildPic);
    ImageIcon img = new ImageIcon(imageURL);
    img.paintIcon(this.buildingPicturePanel, gBuilding, 0, 0);
    could this be becuase the way i am painting the icon?

  • Space between DIV with image and DIV with image background

    I have just about finalized the new design on my website. The only issue I am having now is on the gallery page.  There is a thin space between a DIV with an image and DIV with an image background.  I am using these DIV's to give the illusion of a blue border. If you look at any of the other main pages on the site the space is not there. Any ideas? 
    http://liquidfirefishing.com/index.php
    http://liquidfirefishing.com/gallery/main.php
    Here are a couple of screenshots to show exactly what I mean.

    Hello, 
    both my "IE8" and my "FF 7.01" show the blue boundary lines. Here my screenshots, left side IE8, right side FF:
    Header 1
    Header 2
    Hans-Günter

  • Setting image background transparent

    I want to know how can I set the background of an existing images to transparent. I am a web desginer and currently i want's to change background color of one of my site http://twxdroid.com but here the problem arises that some of my used images background won't match up site background, so someone plz tell me how to change existing image background transparent. I heard about using magic wand selection tool or quick selection tool to make transparent but still can't figure out how to use them.

    • if the Layer is a Background Layer change it to a regular one by double-clicking it
    • make a Selection with whatever Selection Tool is appropriate
    • if you selected the background use Select > Inverse to invert the Selection
    • Layer > Layer Mask > From Transparency
    • if further corrections are needed paint on the Layer Mask – black to hide, white to show the Layer’s content
    • save the layered file as psd, psb or tif
    • File > Save for Web … to save a copy a format that fits your needs (png-24 for example)

  • How to use image load gif of 「GIF87a」 by ByteArray ?

    Hi all:
    I want use image load gif file of 「GIF87a」 by ByteArray, but it not be displayed correctly on the screen, How can I do it , or How to conver 「GIF87a」 to 「GIF89a」 ?
    private function onButtonClick():void {
        fileRef.browse([new FileFilter("Images", "*.jpg;*.gif;*.png;*.swf")]);
        fileRef.addEventListener(Event.SELECT, onFileSelected);
    private function onFileSelected(e:Event):void {
        fileRef.addEventListener(Event.COMPLETE, onFileLoaded);
        fileRef.load();
    private function onFileLoaded(e:Event):void {
        var bytes:ByteArray = e.target.data;
        imageLoader.source = bytes;
    <mx:Image  id="imageLoader" onclick="onButtonClick()">

    Hi zhaojie198281,
    I've made a small modification on your code and it works fine. Try the following code,
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx"
            width="900" height="400">
    <fx:Script>
      <![CDATA[
       private var fileRef:FileReference = new FileReference();
       private function onButtonClick():void {
        fileRef.browse([new FileFilter("Images", "*.jpg;*.gif;*.png;*.swf")]);
        fileRef.addEventListener(Event.SELECT, onFileSelected);
       private function onFileSelected(e:Event):void {
        fileRef.addEventListener(Event.COMPLETE, onFileLoaded);
        fileRef.load();
       private function onFileLoaded(e:Event):void {
        var bytes:ByteArray = e.target.data;
        imageLoader.source = bytes;
      ]]>
    </fx:Script>
    <fx:Declarations>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:layout>
      <s:VerticalLayout paddingTop="10" paddingLeft="10"/>
    </s:layout>
    <s:Button label="Load!" click="onButtonClick()"/>
    <mx:Image id="imageLoader"/>
    </s:WindowedApplication>

  • I have several layers for this image: Background, Moon, Tree, Grass and Clouds.  When I try to use the Move tool to move the Moon, the tool jumps to the Tree layer.  The same thing happens with the other layers as well (except the background layer).  How

    I have several layers for my image: Background, Moon, Tree, Grass and Clouds.  When I try to use the Move tool to move the Moon, the tool jumps to the Tree layer.  The same thing happens with the other layers as well (except the background layer).  How can I keep the move tool from jumpimg to the Tree layer?

    1. Pre-select (highlight) the layer to move in the Layers panel.  or-
    2. [ALT+Right mouse click]  to select the wanted layer in the image window.
    and maybe
    3. Set the PS option to "Auto-select" a layer with cursor hover.  (can be very confusing!)

  • Need to make a 20 second HD clip with a moving image background and text thats flies in...

    Hi all im quite new to after effects and need to make a 20 second HD clip with a moving image background and text thats flies in. I also need to create a basic cross image. If anyone could suggest the best way to go about doing this it would be greatly appreciated. Thank you in advance

    Thank you for both of your reponses and I will try and be clearer:
    what I want to acheive is a HD motion graphic of text which will almost spin onto the screen letter my letter and then a become static word. Behind this I would like to place a moving image clip.
    By 'basic cross image' what im looking to do is use a cruifix shape instead of a 't' on the text.
    I hope this makes sense and thanks again!

Maybe you are looking for