Exracting a transparent image from black background

Hey all! A little bit confused on a project. I have an image that is semi-transparent. I am able to take the black out of the background around it, but am unsure about how to remove the acutal background from behind the image. I need to superimpose this image onto another-hence the background change. Any tips or ideas? I have the newest version of PS. Please help!
Kind regards,
Ashley

Hi,
I am moving your post to the Photoshop General Discussion forum. You should get a response there. (This forum is specifically for the Edit your first photo page.)
Best regards,
Randy Nielsen
Product Integration Manager, Creative Cloud Learning & Training
Adobe

Similar Messages

  • Create transparency image from shape

    Hi,
    I'd like to create the application that create the transparency image from drawing data. the code is as follows.
    BufferedImage img = new BufferedImage(350,350,BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = img.createGraphics();
    GeneralPath gp = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    gp.moveTo(100,100);     gp.lineTo(100,200);
    gp.lineTo(200,200);     gp.lineTo(200,100); gp.closePath();
    g2.setPaint(Color.yellow);
    g2.fill(gp);
    g2.setStroke(new BasicStroke(2));
    g2.setPaint(Color.red);
    g2.draw(gp);
    File outFile = new File("outimg.png");
    ImageIO.write(img,"png",outFile);
    I can create the image from such code, but the image is not transparent since the background is all black. What additional coding I need to make it transparent?
    Thanks,
    Sanphet

    1. use a PixelGrabber to convert the image into a pixel array
    2. (assuming pixel array called pixelArray) :
    if (pixelArray[loopCounter] == 0xFFFFFFFF) { //assuming the black your seeing is not a fully transparent surface
        pixelArray[loopCounter] = pixelArray[loopCounter] & 0x00FFFFFF; //sets alpha channel for all black area to 0, thus making it fully transparent
    }3. recreate an Image using MemoryImageSource
    I'm sure there is a quicker solution using some built in java functions...but hey, I dont' know it!! :)
    Here's a sample class that utilizes these techniques:
    * To start the process, click on the window
    * Restriction (next version upgrade) :
    *     - firstImage must be larger
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class AdditiveBlendingTest extends javax.swing.JFrame implements MouseListener, ActionListener, WindowListener {
        static final int ALPHA = 0xFF000000; // alpha mask
        static final int MASK7Bit = 0xFEFEFF; // mask for additive/subtractive shading
        static final int ZERO_ALPHA = 0x00FFFFFF; //zero's alpha channel, i.e. fully transparent
        private Image firstImage, secondImage, finalImage; //2 loades image + painted blended image
        private int firstImageWidth, firstImageHeight, secondImageWidth, secondImageHeight;
        private int xInsets, yInsets; //insets of JFrame
        //cliping area of drawing, and size of JFrame
        private int clipX = 400;
        private int clipY = 400;
        //arrays representing 2 loades image + painted blended image
        private int[] firstImageArray;
        private int [] secondImageArray;
        private int [] finalImageArray;
        //system timer, used to cause repaints
        private Timer mainTimer;
        //used for double buffering and drawing the components
        private Graphics imageGraphicalSurface;
        private Image doubleBufferImage;
        public AdditiveBlendingTest() {
            firstImage = Toolkit.getDefaultToolkit().getImage("Image1.jpg");
            secondImage = Toolkit.getDefaultToolkit().getImage("Image2.gif");
         //used to load image, MediaTracker process will not complete till the image is fully loaded
            MediaTracker tracker = new MediaTracker(this);
            tracker.addImage(firstImage,1);
         try {
             if(!tracker.waitForID(1,10000)) {
              System.out.println("Image1.jpg Load error");
              System.exit(1);
         } catch (InterruptedException e) {
             System.out.println(e);
         tracker = new MediaTracker(this);
         tracker.addImage(secondImage,1);
         try {
             if(!tracker.waitForID(1,10000)) {
              System.out.println("Image2.gif Load error");
              System.exit(1);
         } catch (InterruptedException e) {
             System.out.println(e);
         //calculate dimensions
         secondImageWidth = secondImage.getWidth(this);
         secondImageHeight = secondImage.getHeight(this);
         firstImageWidth = firstImage.getWidth(this);
         firstImageHeight = firstImage.getHeight(this);
         //creates image arrays
         firstImageArray = new int[firstImageWidth * firstImageHeight];
            secondImageArray = new int[secondImageWidth * secondImageHeight];
         //embeded if statements will be fully implemented in next version
         finalImageArray = new int[((secondImageWidth >= firstImageWidth) ? secondImageWidth : firstImageWidth) *
                 ((secondImageHeight >= firstImageHeight) ? secondImageHeight : firstImageHeight)];
         //PixelGrabber is used to created an integer array from an image, the values of each element of the array
         //represent an individual pixel.  FORMAT = 0xFFFFFFFF, with the channels (FROM MSB) Alpha, Red, Green, Blue
         //each taking up 8 bits (i.e. 256 possible values for each)
         try {
             PixelGrabber pgObj = new PixelGrabber(firstImage,0,0,firstImageWidth,firstImageHeight,firstImageArray,0,firstImageWidth);
             if(pgObj.grabPixels() && ((pgObj.getStatus() & ImageObserver.ALLBITS) != 0)){
         } catch (InterruptedException e) {
             System.out.println(e);
         try {
             PixelGrabber pgObj = new PixelGrabber(secondImage,0,0,secondImageWidth,secondImageHeight,secondImageArray,0,secondImageWidth);
             if (pgObj.grabPixels() && ((pgObj.getStatus() & ImageObserver.ALLBITS) !=0)) {
         } catch (InterruptedException e) {
             System.out.println(e);
         //adds the first images' values to the final painted image.  This is the only time the first image is involved
         //with the blend
         for(int cnt = 0,large = 0; cnt < (secondImageWidth*secondImageHeight);cnt++, large++){
             if (cnt % 300 == 0 && cnt !=0){
              large += (firstImageWidth - secondImageWidth);
             finalImageArray[cnt] = AdditiveBlendingTest.ALPHA + (AdditiveBlendingTest.ZERO_ALPHA & firstImageArray[large]) ;
         //final initializing
         this.setSize(clipX,clipY);
         this.enable();
         this.setVisible(true);
         yInsets = this.getInsets().top;
         xInsets = this.getInsets().left;
         this.addMouseListener(this);
         this.addWindowListener(this);
         doubleBufferImage = createImage(firstImageWidth,firstImageHeight);
         imageGraphicalSurface = doubleBufferImage.getGraphics();
        public void mouseEntered(MouseEvent e) {}
        public void mouseExited(MouseEvent e) {}
        public void mousePressed(MouseEvent e) {}
        public void mouseReleased(MouseEvent e) {}
        public void windowActivated (WindowEvent e) {}
        public void windowDeiconified (WindowEvent e) {}
        public void windowIconified (WindowEvent e) {}
        public void windowDeactivated (WindowEvent e) {}
        public void windowOpened (WindowEvent e) {}
        public void windowClosed (WindowEvent e) {}
        //when "x" in right hand corner clicked
        public void windowClosing(WindowEvent e) {
         System.exit(0);
        //used to progress the animation sequence (fires every 50 ms)
        public void actionPerformed (ActionEvent e ) {
         blend();
         repaint();
        //begins animation process and set's up timer to continue
        public void mouseClicked(MouseEvent e) {
         blend();
         mainTimer = new Timer(50,this);
         mainTimer.start();
         repaint();
         * workhorse of application, does the additive blending
        private void blend () {
         int pixel;
         int overflow;
         for (int cnt = 0,large = 0; cnt < (secondImageWidth*secondImageHeight);cnt++, large++) {
             if (cnt % 300 == 0 && cnt !=0){
              large += (firstImageWidth - secondImageWidth);
             //algorithm for blending was created by another user, will give reference when I find
             pixel = ( secondImageArray[cnt] & MASK7Bit ) + ( finalImageArray[cnt] & MASK7Bit );
             overflow = pixel & 0x1010100;
             overflow -= overflow >> 8;
             finalImageArray[cnt] = AdditiveBlendingTest.ALPHA|overflow|pixel ;
         //creates Image to be drawn to the screen
         finalImage = createImage(new MemoryImageSource(secondImageWidth, secondImageHeight, finalImageArray,
              0, secondImageWidth));
        //update overidden to eliminate the clearscreen call.  Speeds up overall paint process
        public void update(Graphics g) {
         paint(imageGraphicalSurface);
         g.drawImage(doubleBufferImage,xInsets,yInsets,this);
         g.dispose();
        //only begins painting blended image after it is created (to prevent NullPointer)
        public void paint(Graphics g) {
         if (finalImage == null){
             //setClip call not required, just added to facilitate future changes
             g.setClip(0,0,clipX,clipY);
             g.drawImage(firstImage,0,0,this);
             g.drawImage(secondImage,0,0,this);
         } else {
             g.setClip(0,0,clipX,clipY);
             g.drawImage(finalImage,0,0,this);
        public static void main( String[] args ) {
         AdditiveBlendingTest additiveAnimation = new AdditiveBlendingTest();
         additiveAnimation.setVisible(true);
         additiveAnimation.repaint();

  • How can I remove an image from its background and save it? (Photoshop cs6)

    Hello,
    I am very new to the photoshop world and am trying to remove an image from its background ( as a stand-alone) and save it. Is there a way to do this in Photoshop CS6?  I have looked at tutorials but only found how to remove the image but not how to save the image as a stand alone with no background.
    Any help would be appreciated
    Erika

    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.

  • Problem: importing a transparent image from Photoshop to Premiere.

    Dear Adobe community,
    I am trying to import a transparent image from Photoshop to Premiere Pro CC. Whatever file format I choose to export from Photoshop, Premiere Pro CC will not import the file correctly. When I import is, two things occur: 1) the image gets imported, but the white background is still there or 2) the image gets an error "The importer reported a generic error".
    Does anyone have an idea how I can get an image with a white background transparent into Premiere Pro CC.
    Specs:
    MacBook Pro (Retina, 13-inch, eind 2013)
    2.8 GHz Intel Core i7
    16GB RAM
    1536MB Intel Iris videocard
    Thanks!
    Christiaan

    You need to make sure the image has an alpha channel.
    Images like jpeg dont have an alpha channel.
    Psd or png do and the image has to be RGB.
    Make sure the background in PS is also transparant.

  • Using binarize... Getting Tiff Image in Black Background..

    Hi,
    Basically my subject summarizes my problem, but I am trying to write some text to a blank JPEG file and then create a Tiff file from that JPEG...
    But When i use the binarize i am getting the image as black background and the resolution is not that great...
    I am using binarize, because i need to use TIFFEncodeParam.COMPRESSION_GROUP4 but i was getting bi-level error, that is why i am using binarize to create a GROUP4 with black and white color to minimize the file size...
    I am posting the source code, i would appreciate someone can take a look at this code and figure out why i am getting black background...in the tiff file...
    Any help will be greatly appreciated...
    Thanks in advance...
    ========================================
    import javax.swing.UIManager;
    import java.awt.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    public class Application1 {
    private boolean packFrame = false;
    //Construct the application
    public Application1() {
    Frame1 frame = new Frame1();
    frame.setVisible(true);
    //Main method
    public static void main(String[] args) {
    new Application1();
    ================================================
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import com.borland.jbcl.layout.*;
    import com.sun.image.codec.jpeg.*;
    import com.sun.media.jai.codec.*;
    import javax.media.jai.*;
    import java.awt.image.BufferedImage;
    import java.awt.image.RenderedImage;
    import java.awt.image.DataBuffer;
    import java.awt.geom.GeneralPath;
    import java.io.*;
    import java.awt.image.renderable.ParameterBlock;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    public class Frame1 extends JFrame implements java.io.Serializable {
    private JPanel contentPane;
    private JButton jButton1 = new JButton();
    public static final String DEFAULT_FILE = "blank.jpg";
    private static RenderedImage img;
    //Construct the frame
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    //Component initialization
    private void jbInit() throws Exception {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    jButton1.setBounds(new Rectangle(125, 87, 79, 27));
    jButton1.setText("jButton1");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton1_actionPerformed(e);
    contentPane.setLayout(null);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    contentPane.add(jButton1, null);
    //Overridden so we can exit when window is closed
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    void jButton1_actionPerformed(ActionEvent e) {
    String fileName = DEFAULT_FILE;
    // Read the image from the designated path.
    System.out.println("load image from '" + fileName+"'");
    PlanarImage src = JAI.create("fileload", fileName);
    // Generate a histogram...
    Histogram histogram = (Histogram)JAI.create("histogram", src).getProperty("histogram");
    // Get a threshold equal to the median..
    double[] threshold = histogram.getPTileThreshold(0.5);
    PlanarImage dst = JAI.create("binarize", src, new Double(threshold[0]));
    BufferedImage bi = dst.getAsBufferedImage();
    Graphics2D big = bi.createGraphics();
    Graphics2D g2 = bi.createGraphics();
    big.setFont(new Font("Dialog", Font.PLAIN, 20));
    big.setColor(Color.black);
    big.drawString("Data/Time Created:" + new java.util.Date(), 80, 210);
    big.drawString("POLICY NUMBER: 1711215 NAME OF CALLER: BENEFICIARY", 80, 230);
    big.drawString("Requested: Loan Request XXXXXXXXXXXXXXXXXXXXXXXXXXXXX Current Loan Value: $0.00", 80, 270);
    g2.drawImage(bi, 0, 0, null);
    try {
    File file = new File("test.tiff");
    FileOutputStream out = new FileOutputStream(file);
    TIFFEncodeParam params = new TIFFEncodeParam();
    params.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4);
    ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF",out, params);
    if(encoder == null) {
    System.out.println("imageEncoder is null");
    System.exit(0);
    encoder.encode(bi);
    System.out.println("DONE!!!");
    catch (Exception ex) {

    try this:
    BufferedImage bi = new BufferedImage(1728,500,BufferedImage.TYPE_BYTE_BINARY);
    Graphics2D big = bi.createGraphics();
    Graphics2D g2 = bi.createGraphics();
    big.setFont(new Font("Dialog", Font.PLAIN, 20));
    big.setColor(Color.WHITE);
    big.fillRect(0,0,1728,500);
    big.setColor(Color.BLACK);
    big.drawString("Data/Time Created:" + new java.util.Date(), 80, 210);
    big.drawString("POLICY NUMBER: 1711215 NAME OF CALLER: BENEFICIARY", 80, 230);
    big.drawString("Requested: Loan Request XXXXXXXXXXXXXXXXXXXXXXXXXXXXX Current Loan Value: $0.00", 80, 270);
    g2.drawImage(bi, 0, 0, null);

  • I saw Corey Barker do a demo where he extracted an image from the background, then cleaned up the edge with a process that allowed him to de-fringe it.  I can't remember how he did it. And I can't find it.  Help!

    I saw Corey Barker do a demo a few weeks ago where he extracted an image from the background, then used a technique I was not familiar with to clean it up. You selected the area, then did something that involved going either to edit or select, then there was a dialog box that allowed you to dial it in, depending on the color background you were removing.  I can't find this anywhere. Can't remember.  It's driving me crazy!  If someone can help me find this, I would be very glad and grateful. Thanks!  Laura

    In technical support, sometimes you have to make educated guesses. I'm sorry that you were offended.
    iTunes does prompt when it is going to erase a device, and the message is clear.
    She said in her message that she was able to successfully sync the old ipad. This indicated to me that itunes wiping the data was not an issue, because either it had been setup at the apple store (in which case it doesn't actually wipe the ipad despite saying it will*) (*based on a single case I saw), or because the itunes media folder was migrated.
    Furthermore, my solution was to tell her how to backup her ipad (by either doing it manually, or as a last resort, by deleting the corrupt backup -- that she couldn't access anyway.)
    I got that last part of the instructions from the "Taking Control of your iphone" book which I found samples of when I did a google search for "corrupted backup itunes".
    She marked this as a solution, so it worked for her.

  • Copying images with transparency produces a black background.

    When images are copied from Firefox and pasted elsewhere (Paint, PSP, Photoship, etc.) any transparency becomes opaque black. This makes it difficult to edit the image if the transparency was near black pixels. Is there any way to change the colour to something else, or at least, white?

    No, you will have to save the image to disk and open the file in your image editor. You can try if it works if you drag the file in the editor.

  • Odd frames when printing transparency PSD on black background on Illustrator CS4

    I don't know why but any PSD file that have transparency in it and placed on an illustrator document, printed with those frames around it (see example JPEG file that  I added). I tried to print directly to the printer and got those frames. I tried to create a postscript before and then PDF throe the distiller and still, the PDF print those frames. You can see the PDF that I added and examine it. You will see under the "output preview" that the parameters of the black background is the same around.
    What is that?!

    I can't use RGB profile if I want to be precise with my works.
    I found the problem and how to fix it.
    I think it is a problem with the RIP of the printer. The printer receive vector, raster and transparency object together and needs to flatten to a single image - it doesn't succeed.
    So, if I send to the printer from Illustrator, under "Advanced" I use customize pref. by tuning it to all raster and not vector at all the print printed good.
    It's so primitive and stupid that with a new printer I still need to do the RIP with the application.

  • How do you create transparent text with black background in LiveType for use in Final Cut??

    I would like to bring in movies or projects from LT that have transparent text ("alpha" layer?) and a solid background. The goal is to layer fcp video under the animated text generated in LT so that the video layer fills the transparent text layer. I know you can matte to movie or image in LT, but would prefer to do this in FCP. Long story short, need a text transparency from LT. Thanks!

    Video track 1: Your background.
    Video track 2: White text on a black background.
    Video track 3: The fill image for the letters.
    Right click on the clip on track 3. From the drop down menu, choose Composite Mode > Travel Matte Luma.

  • Transparent Flash has black background

    I have a video flash file created in Premiere Pro CS4 which I keyed out the background, exported as a FLV/F4V with an encoded alpha channel. I place the flash on a JPG in Dreamweaver CS4 and want the movie to run transparent, but I always get a black box surrounding my movie. I use the "wmode" as "transparent" in the flash dialog box, but this does not eliminate the black background around the movie. Any suggestions?

    Transparency with *.flv's works for me when I place the background on the bottom layer in the Flash program project (*.fla) and place the video on the layer above, in the Flash program project. Publish this "Flash Movie" from Flash and cut and paste the Flash code from the "Published" HTML page into either the table cell or div on your final Dreamweaver page depending upon whether you are building an "old school" table based page or a CSS based page.
    If you are creating one of those "floating" over the top, Web page movies, someone in the Flash or Dreamweaver forum should be able to help you with that.
    Also, in Premiere, you should be working in a "Desktop mode" sequence with "Square pixels" selected.
    Here are the settings to get the flv to encode with an alpha channel:

  • How To Take Extract Image from a Background?

    I have a pic of a women wearing headphones, the background is
    white but i want to show her on a black background
    So i have created a blackground in fireworks.. how do i now
    get the women out of the background she is in and onto my black
    ground without grabbing any of the background surrounding her??
    What tool do i use
    Where do i find the tool
    and how do i use it thanks?

    jono25 wrote:
    > I have a pic of a women wearing headphones, the
    background is white but i want
    > to show her on a black background
    >
    > So i have created a blackground in fireworks.. how do i
    now get the women out
    > of the background she is in and onto my black ground
    without grabbing any of
    > the background surrounding her??
    >
    You can do this a couple ways:
    1) Use the Magic wand to select the white background and
    delete it, then
    touch up the edges around your subject.
    2) Create a vector or bitmap mask to hide the white
    background. This is
    more flexible and less destructive to the original image, as
    no pixels
    are actually deleted from the image. This is the method I
    would recommend.
    Vector masks give you more control over fine tuning the mask,
    and it
    will give you a chance to get some practice with the pen
    tool.
    Jim Babbage - .:Community MX:. & .:Adobe Community
    Expert:.
    Extending Knowledge, Daily
    http://www.communityMX.com/
    CommunityMX - Free Resources:
    http://www.communitymx.com/free.cfm
    .:Adobe Community Expert for Fireworks:.
    news://forums.macromedia.com/macromedia.fireworks
    news://forums.macromedia.com/macromedia.dreamweaver

  • Tried to install the latest update on my ipad. i get an image of "itunes" with a connecting cord. hasnt changed in three hours. if i turn it off, it goes right back to same image on black background. i am stuck, please help me, thanks

    i tried to install the latest update on my ipad. i get an image which says I tunes with a cord to plug in. it is on a black background.. it has been like this for three hours now. if i turn it off and then on again that is the only page that appears. i am stuck. please can anyone help me? thanks.

    It's too bad you lost stuff. I would recommend that you back stuff up before the next one. For example, iOS8 will be out sometime this fall. Just in case you experience the same thing again, do a backup before you do the update.

  • Extracting an image from its background

    Hi I have the attached image from which I am trying to produce a logo, eventually exporting it to illustrator.  I have retaken the photo of the charcoal drawing so it is placed on the same paper it was drawn on and have managed to get a reasonable amount of space on the right hand edge but the left hand edge is proving beyond me.  As there are so many greys and light greys, it is proving impossible to get a good selection.  When I place the logo in my wordpress site it looks awful on the right hand edge.
    Please see second screenshot to see what I am trying to explain.
    I tried doing a live trace in illustrator which was also a dismal failure sigh!
    Appreciate any suggestions thanks!

    You probably simply need to hang in there much longer. Sorry to say so, but sounds like you are expecting simple shortcuts and "Which button must I push?" solutions. Live Trace will work just fine, but naturalyl you will need to spend some time with it and still have to spend a lot of time cleaning things up manually afterwards. Likewise, in PS you will have to spend some time and work your way through the selection tools and manual cleanup by painting on the resulting mask/ channel... Not sure what else to tell you. Some things simply are just hard manual labor even in this day and age...
    Mylenium

  • Removing an image from a background by cropping

    I am trying to place a shape on an image and remove it from the photo, creating just the picture within the shape.  When I follow instructions, I get a lovely shape around my image, but the image isn't removed.  It just sits in a white-checkered background.
    How do I get rid of the white background?

    joni1129 wrote:
    I am trying to place a shape on an image and remove it from the photo, creating just the picture within the shape.  When I follow instructions, I get a lovely shape around my image, but the image isn't removed.  It just sits in a white-checkered background.
    How do I get rid of the white background?
    The white-checkered background is a visual reference for transparency. (It won't print.) To keep the transparency, you need to save in a format that supports transparency, PSD, TIF (with save transparency checked), PNG, or GiF. If you save in a format such as JPG that doesn't support transparency, the transparency is replaced by white.
    Edit: If you are transferring the image into another software application, you may have to save the selection along with the image. Select<Save Selection. You'd have to also check which of the formats that application accepts.

  • JAI - Saved image has black background (unless screen config is True Color)

    Hi!
    I'm trying to save images using JAI's codecs. Everything is okay if screen config is True Color, but if in 256 colors (or even in 65536 colors) the background of my images looks very dark...
    Can you please have a look at the code bellow (and try it with some different screen configs). I'm really stuck with that issue; any suggestion may help...
    NOTE:
    - I've noticed this problem when using JAI's jpeg codec.
    - The problem occurs with both JDK 1.3 and 1.4.
    - The problem does not occur (only) if screen config is True Color.
    - You must rerun the code after changing screen config.
    Thanks for help...
    cbmn2
    +++++++++++++++++++
    import java.awt.*;
    import com.sun.media.jai.codec.*;
    import javax.media.jai.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.io.*;
    import java.awt.image.renderable.*;
    public class Test2 extends JFrame
    String codecFormat = "jpeg";
    String outFilePath = "./test.jpg";
    JPanel jp;
    JButton jb;
    MyActionListener mal = new MyActionListener();
    public Test2()
    setSize(800,600);
    Container cp = getContentPane();
    cp.setLayout(null);
    jp = new JPanel(){
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    Dimension dim = getSize();
    // initialization...
    //==================
    g.setColor(Color.white);
    g.fillRect(0, 0, dim.width, dim.height);
    // some drawing...
    //=================
    int inset = 10;
    g.setColor(Color.red);
    g.fillRect(inset, inset, dim.width-2*inset, dim.height-2*inset);
    jp.setBounds(10,10,400,300);
    jp.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
    cp.add(jp);
    jb = new JButton("Save image to '"+outFilePath+"'");
    jb.setBounds(10,320,400,50);
    jb.addActionListener(mal);
    cp.add(jb);
    class MyActionListener implements ActionListener
    public void actionPerformed(ActionEvent ae)
    Object source = ae.getSource();
    if (source == jb)
    jb_actionPerformed(ae);
    public void jb_actionPerformed(ActionEvent ae)
    try {
    Image image = jp.createImage(jp.getWidth(), jp.getHeight());
    jp.paint(image.getGraphics());
    saveImage(image, outFilePath, codecFormat);
    JOptionPane.showMessageDialog(this, "File '"+outFilePath+"' is now saved...");
    catch(Exception e) {
    JOptionPane.showMessageDialog(this, "Oops! An exception occured...");
    public void saveImage(Image image, String filePath, String format) throws Exception
    // conversion Image => RenderedImage
    //==================================
    RenderedImage renderedImage = JAI.create("AWTImage", image);
    ParameterBlock pb = new ParameterBlock();
    pb.addSource(renderedImage);
    pb.add(DataBuffer.TYPE_BYTE);
    renderedImage = JAI.create("format", pb);
    // saving file
    //=============
    JAI.create("filestore", renderedImage, filePath, format);
    public static void main(String[] args)
    (new Test2()).setVisible(true);
    }

    try this:
    BufferedImage bi = new BufferedImage(1728,500,BufferedImage.TYPE_BYTE_BINARY);
    Graphics2D big = bi.createGraphics();
    Graphics2D g2 = bi.createGraphics();
    big.setFont(new Font("Dialog", Font.PLAIN, 20));
    big.setColor(Color.WHITE);
    big.fillRect(0,0,1728,500);
    big.setColor(Color.BLACK);
    big.drawString("Data/Time Created:" + new java.util.Date(), 80, 210);
    big.drawString("POLICY NUMBER: 1711215 NAME OF CALLER: BENEFICIARY", 80, 230);
    big.drawString("Requested: Loan Request XXXXXXXXXXXXXXXXXXXXXXXXXXXXX Current Loan Value: $0.00", 80, 270);
    g2.drawImage(bi, 0, 0, null);

Maybe you are looking for