BufferedImage Combining images

I am working with the BufferedImage class. Basically I have two images
that I want to combine together BEFORE I paint them to the screen. Can someone please show me how to do this. I have not been able to figure this out, although I think it will be easy for a seasoned Java Graphics developer.
1 Image FirstImage = getToolkit().getImage("front.gif");
2 Image MyButtonImage = getToolkit().getImage("buttons.gif");
3 MediaTracker mt = new MediaTracker(this);
4 mt.addImage(FirstImage, 1); mt.addImage(MyButtonImage, 2);
5 bi_BackGround = new BufferedImage(FirstImage.getWidth(this),
6 FirstImage.getHeight(this),
7 BufferedImage.TYPE_INT_ARGB);
8 bi_MyButtonImage = new BufferedImage(MyButtonImage.getWidth(this),
9 MyButtonImage.getHeight(this),
10 BufferedImage.TYPE_INT_ARGB);
11
12 Graphics2D dcBackGround = bi_BackGround.createGraphics();
13 Graphics2D dcButton = bi_MyButtonImage.createGraphics();
14
15
16 dcBackGround.drawImage(FirstImage, 0,0, null);
17 dcBackGround.drawOval(10,10,5,5); // Draw an oval on the first image
18 // I am under the assumption that lines 16, and 17
19 dcButton.drawImage(FirstImage, 0,0, null);
// Next draw image of a button on the first image.
20 dcButton.drawImage(MyButtonImage, 0,0, null);
21 // We now have a background image with a button on it.
22 }
23
24 public void paintComponent(Graphics g) {
25 super.paintComponent(g);
26 Graphics2D g2D = (Graphics2D) g;
27 g2D.drawImage(bi_MyButtonImage, x, y, this); // Display final image
28}

Actually the code could be working but I have just found out that
only a portion of the first image is being shown. Then I think the second image is overlayed with the same dimensions of the first image, thus hiding the second image. For some reason, the hieght of the bitmap is not correct. Note that this is how I get the height.
FirstImage.getWidth(this),
FirstImage.getHeight(this)
Please help

Similar Messages

  • Combining images to PDF in folder based on prefix

    I have an arbitary folder with images in them, that are named like this:
    00_01.tiff
    00_02.tiff
    00_03.tiff
    00_03.tiff
    01.tiff
    02-1_01.tiff
    02-1_02.tiff
    02-2_01.tiff
    02-2_02.tiff
    I want to combine all the files starting with 00 into a new pdf 00.pdf, all starting 01 to 01.pdf,  all starting with 02-1 to 02-1.pdf and all starting with 02-2 to 02-2.pdf
    In short the rule would be:
    if text 3 in fileName = "_" then
         set newFileName to text 1 thru 2 of fileName
    else
         set newFileName to text 1 thru 4 of fileName
    end if
    It is easy to combine files to PDF's with Automator, but introducing this logic and doing the combining in Applescript is out of my league.
    Does anybody have some suggestions on how I should go about solving this?
    Best regards,
    Knut

    Jacques Rioux wrote:
    Does the script should search in the subfolders?
    No, I did not intend it to search through subfolders. I have thought about maybe first putting each group of files in to subfolders, and then iterate through the folders and do the PDF conversion then. That would be quite close to what the script you wrote is doing. More about that at the end of this reply.
    Do you have multiple image formats (the name extension) to find in the source folder or in subfolders?
    No, there will only ever be .tiff images in the folder. The contents of the folder is created by another script (as a part of a bigger workflow).
    Do you have any PDF documents or PDF images  to find in the source folder or in subfolders that you want to combine?
    No, there will only be images in .tiff format. I mistyped in my previous post - it should have said .tiff there too, and not .pdf. Sorry about that.
    xx.tif and xx_y.tif : Is it the number in xx can be the same or always different?
    If the answer is not always different, (11.tiff and 11_2.tiff) Does the script should create one PDF or two PDF?
    If the answer is two PDF, how do you rename the new PDF file? --> (11.pdf and 11_2.pdf) both must be renamed "11.pdf"
    I will remove the xx.tiff as a possibility. We will only have xx_yy.tiff or xx-z_yy.tiff to care about, and not xx.tiff.
    I will give you some background information, maybe it is easier when understanding the use case. You can skip to the table below if this is not relevant. The reason for this naming convention, is so that yet another script can finalize the workflow later, when doing renaming based on the output name of the created PDF-file. My workflow is for digital archiving of sheet music.
    The entire workflow is like this:
    Scanning the sheet music.
    Converting pdf-files to tiff.
    Cleaning, straigthening and convert from grayscale to b/w with ScanTailor
    Rename output files to the naming scheme I describe.
    Convert the tiff images to pdf, per part.  (this is the part I'm asking about here)
    Renaming all the files to fit the archiving scheme.
    Grouping and sorting the files, and creating zip-archives.
    Archiving the entire digital copy of the set in our digital archive.
    For our case, we're only interested in item 5 in the list. Another series of scripts and Automator workflows take care of the rest.
    Each music piece consists of several parts.
    In the filing system I have created, each part has a prefix with the xx-number, like this:
    00 = Score
    01 = Soprano cornet
    02 = Solo cornet
    17 = BbBass
    18 = Percussion
    The final files will have a name like (only an example):
    02_SoloCn_31_SilentNight_Gordon.pdf
    For some pieces there are more than one solo cornet part. That's why we get the z-component, to differentiate between the parts:
    02-1 = Solo cornet 1 --> will get filename 02_SoloCn1_31_SilentNight_Gordon.pdf
    02-2 = Solo cornet 2 --> will get filename 02_SoloCn2_31_SilentNight_Gordon.pdf
    Many pieces has more than one page per part. That is where the yy component of the file name comes in, the only reason for the yy component is to keep all the pages in the correct order to make it easy to combine them programatically:
    02-1_10.tiff = Solo cornet 1, page 1
    02-1_11.tiff = Solo cornet 1, page 2
    02-1_12.tiff = Solo cornet 1, page 3
    Here is a table with the pattern, example of a possible filename and what the output pdf should be called:
    Pattern
    Example file name
    Output pdf
    xx_yy.tiff
    01_10.tiff
    01_11.tiff
    01_12.tiff
    01_13.tiff
    01.pdf
    xx_yy.tiff
    12_10.tiff
    12_11.tiff
    12_12.tiff
    12.pdf
    xx-z_yy.tiff
    02-1_10.tiff
    02-1_11.tiff
    02-1_12.tiff
    02-1.pdf
    xx-z_yy.tiff
    02-2_10.tiff
    02-2_11.tiff
    02-2_12.tiff
    02-2.pdf
    Is it possible that there would be other characters after the pattern? --> example: 33_2test.tiff, 40-4_99ball.tiff
    No, all the files will have just the components described above in the file name. No need for exception handling, since this is a tightly controlled workflow.
    As i mentioned earlier in this reply, I have played with the thought of first running a script to sort all the files for one part into a subfolder with the correct name.
    This I can do with the following script (I guess it would be more efficient with shell script or using System Event to do the moving):
              tell application "Finder"
    set thisfolder to (choose folder)
    set mylist to every file in thisfolder as alias list
    repeat with eachfile in mylist
    set filename to name of eachfile
    if (character 3 of filename is "-") then
    set prefix to characters 1 thru 4 of filename as text
    else
    set prefix to characters 1 thru 2 of filename as text
    end if
    try
    set newfolder to ((thisfolder as text) & prefix) as alias
    on error -- file not found
    set newfolder to make new folder at thisfolder with properties {name:prefix}
    end try
    move eachfile to newfolder
    end repeat
       end tell
    After this, all the files have moved to folders with the folder name corresponding to the part number, like this:
    01/01_10.tiff
    01/01_11.tiff
    02-1/02-1_10.tiff
    02-1/02-1_11.tiff
    and so on...
    It would perhaps be easier to extend on this script, or create a new one, that will iterate each subfolder in a folder, and run the Automator action for combining images to files with each iteration?
    What do you think? I'm sorry if this was too much information. Do not hesitate to ask if something is unclear (I bet it is!).
    I really appreciate your help, Jacques!
    Knut

  • Creating BufferedImage from Image

    I've figured out one way to create a BufferedImage from an Image, but I'm sure it's not the best way.Image im = Toolkit.getDefaultToolkit().getImage(files.getAbsolutePath());
    JLabel jl = new JLabel(new ImageIcon(im));
    BufferedImage bim = new BufferedImage(im.getWidth(null), im.getHeight(null), BufferedImage.TYPE_BYTE_INDEXED);
    Graphics g = bim.getGraphics();
    jl.paint(bim.getGraphics());
    This works, but I'm sure there has to be a better/easier way. Any suggestions?
    Thanks,
    m

    close, the best way is this...
    public BufferedImage createBufferedImage(Image img)
    BufferedImage bimg = new BufferedImage(img.getWidth(null),img.getHeight(null),BufferedImage.TYPE_INT_RGB);//or whatever type is appropriate
    bimg.getGraphics().drawImage(img,0,0,null);
    return bimg;
    }

  • Cropping and Combining Images

    Is there a way to take multiple images (i.e. congruent squares of a map) and crop and combine them to form one image of a given size?
    For example, if the user asks for a map of a certain area with a bounding box of 40 to 57 (x) and 33 to 50 (y), I want to return an image made up of individual smaller squares from the map database cropped to cover only those coordinates. Unforturnately the map in our database is a series of squares each 10 by 10 (i.e. (0-10, 0-10), (10-20, 0-10), and so on). So I need some way to take the (40-50, 30-40), (50-60,30-40),(40-50, 40-50), and (50-60,40-50) images and combine and crop them to make an image that covers only (40-57,33-50).
    Is there a class somewhere that allows for such an operation, or if not, does anyone know an easy way to do this?

    I'll assume you are looking to create an arbitrary rectangular image from a domain of rectangular images that collectively form a contiguous grid. Right?
    This is a fairly simple problem to solve...
    1. Create a BufferedImage with bounds equal to your bounding box. Then create a Graphics2D from the BufferedImage via BufferedImage.createGraphics().
    2. Determine the images in the database that intersect your bounding box.
    3. For each intersecting image determine the portion of the image that is contained in the bounding box. Then translate each image portion's coordinates to your bounding rectangle's coordinates.
    4. Using the graphics from step 1 call Graphics.drawImage() to render each image portion to the BufferedImage using the translated coordinates.
    5. The BufferedImage is now an in memory representation of your bounding box selection.

  • How to combine images from several different shoots into one

    Have LR 3.6 for Win xp.
    I have 4 differernt photo shoots that I want to combine into one big single catalogue.  I want to be able to rank and choose images from all 4 shoots at the same time so I can get the best ones identified.
    Each shoot is already in its separate catalogue but I cant figure out how to get all 4 shoots to show up at once so I can rank the best shots and maybe even make a collection of my best images from the 4 shoots.
    How might I do this??
    Thanks Suzzie

    My primary suggestion is that you watch the many videos by Julianne Kost provided in the Adobe site about organizing in the Library Module in LR 4, or read one of the many good LR books. If you want to venture on your own here's a very shorthand description of one of many ways to do what you want. Choose which Catalog you want to use. Open that Catalog and choose "Import from Another Catalog" under the File Menu in the Library Module. Select the images and import them to your chosen main catalog. Once all are in the same Catalog either Keyword all similar images you wish to compare, or make separate Collections of each one. Use the Compare function in the Library ("c" key) and eliminate the one you don't want. Unless you have one client viewing your images in LR and you don't want them to see that you have other images for other clients, I would suggest you use only a single catalog from here on out.

  • How to combine images using layers

    what is the best way to combine and edit different images into one cohesive photo in a collage-esque, style? i.e. the background from one photo, the subject from another, ect.

    I don't know if this is the "best" way, but it's one way.
    Create a new file of required dimensions & resolution for your final product.
    SaveAs Canvas.psd.
    Open image one and select or inverse select or mask out the unwanted parts and delete them.
    Ctrl+A to select what's left. 
    Copy & paste into Canvas.psd. 
    Save Canvas. 
    Close image one.
    Repeat with other images.
    Nancy O.

  • Converting PDF/A to PDF while combining images

    Thanks in advance for your assistance!
    I have a quantity of PDF/A that I need to convert to standard PDFs. However, here's the wrinkle: each file has separate images that are layered over each other. I really need one image that has all the separate images combined. Further information: there's embedded text that needs to be preserved.  An example image is here.  An example of what it needs to look like is here.
    How do I do this in Acrobat Pro XI? I've tried a bunch of different things but had no success. I was hoping someone with more experience has some suggestions.  Thanks!

    Well, the situation is this. We have an OCR program that reads tiffs of historic newspapers and makes PDFs of them. Then we have another piece of software that creates an XML (containing the text and related metadata) and PNG for screen display using the PDF as the source. Then these are ingested into a third software package that makes the newspaper pages searchable and displays the PNG via the web. It then offers the PDF as a download. 
    This works for us BUT we upgraded the OCR program and accidentally changed from PDF to PDF/A. For whatever reason the PDFs output with a single image but PDF/A takes any pictures or drawings and makes the separate image layers while "cutting" the pictures out of the main image.  The software that creates the XML can only process the first image it finds in the PDF. We didn't detect the change until we had OCRed about 30,000 pages.
    We unfortunately pay per page for the OCRing. So I'm hoping to fix the incorrect files rather than going back and re-OCRing the whole batch and have to pay again on the same pages.  We corrected the process and now PDFs come out of the OCR with just one image. So moving forward we're fine.
    So that's why I'm trying to find a way to flatten the images.

  • Newbie: Saving combined image adjustments

    Hello everyone,
    After using the Lightroom betas and loving it, I made the switch to Aperture. I love everything about Aperture except for one thing. I understand how to save a preset for each adjustment; white balance, levels, etc. However, I can't figure out how to make a preset combining all the adjustments I made.
    I've searched high and low trying to figure this out. Am I missing something?
    Thank you all!

    I don't know that it's possible.
    However, what you could do would be to use lift and stamp to accomplish this. When you lift from an image, you get all its adjustments. So if you lifted from an image with this entire set of presets, everything you stamped would get them (color temperature, sharpening, levels, etc.).
    Something that would work then would be to set up a set of reference images that you could lift from. This is a bit ugly, but it should work. Here's to submitting feedback for a nicer way

  • How to combine images?

    Dear Friends,
    I would like to preview a thumbnail image which is combined from different image files.
    I have 4 rgb thumbnail Images, actually they are created by CMYK image fiiles. if I want to combine these image into an image for preview. How can I do?
    I need to convert rgb to CMYK? and then convert back to rgb?
    I have no idea how to do this.., please help ~~
    Does anyone has tried to make this type of function or alorighm? I would be appreciate that if you can teach me and provide me some examples.
    Thanks for kindly help !!

    If you want to do anything complicated with raster images you want the Java Advanced Imageing package. It's not part of the standard JDK but it's available free on Sun's site. It provides a wide range of filters which you use to construct a "pipeline" from your image source to a display, or back to a new image file.
    Filters include mosaic (for placing images side by side) and colour space conversion filters.
    I think you'll find what you want (though there's a lot of documentation to wade through).

  • Combine images into one image

    I have 13 small images 100x100, and I would like to combine them into one 1300x1300 image.  I have all the latest vision assistant and IMAQ software.  I can't figure out an easy way to do this using Labview?  Any help would be greatly appreciated.
    Kevin Baker

    I am not too familiar with IMAQ but have done LV image processing where you can use an array to represent the data (I think IMAQ uses some border pixels in their array to accomidate for image processing near image edges).  You can initialize a 700x700 array (use a numeric type which agrees with your image bit depth, then for each image use the replace array subset with the column/ row corresponding to the x,y location of the origin (upper left  corner) of each image to replace, the length of each subset is equal to the width and height (100 in this case) of the inserting image.  So for image 1 the replace subset would be:
    column = 300, length = 100, row =0, length 100.
    Repete this for all 13 images.  As for the IMAQ conversion I dont know the answer since I dont have a copy of IMAQ.
    Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • BufferedImage to Image

    ok im doing this...
    public class Map{
      static ImageIcon image;
      public Map() {
      public void paint(Graphics g){
        Graphics2D g2d = (Graphics2D)g;
        Image im = Toolkit.getDefaultToolkit().getImage("images\\map.gif");
        g2d.drawImage(im,0,0,Config.map);
        int width = 400;
        int height = 400;
        BufferedImage bimage = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.OPAQUE);
        image = new ImageIcon(bimage);
    }Config.map is a JPanel
    When i do this i just get an empty ImageIcon. why is that?

    Yeah ill create the image outside...
    The reason i want to convert an image to a bufferedImage and then back is because i want to draw on it before i convert it back to an image. (which then gets put into the ImageIcon so that i can use it as a JLabel...
    So is this the right way?
    Image im = Toolkit.getDefaultToolkit().getImage("images\\map.gif");
    BufferedImage thumbImage = new BufferedImage(400,400,BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = im.createGraphics();
    g2d.drawImage(im,0,0,400,400,null);
    BufferedImage bimage = g2d.getDeviceConfiguration().createCompatibleImage(400, 400, Transparency.OPAQUE);
    ImageIcon ima = new ImageIcon(bimage);Cause if i do that i get a black image... not sure why...

  • Combining Image Maps and Dropdown Menus

    In Dreamweaver 5.5, I want to create a dropdomn from a sliced graphic. There is a toolbox called the Tag Inspector that contains 3 tabs. The Behaviors tab with the + sign brings up a menu, from which I should to be able  select the Show Pop-Up Menu -- but it's not there!
    Where can I find a toll to create dropdowns from image maps?

    Image maps don't produce drop-down menus.  You would be better served with a CSS styled list menu.
    Example 1 (same styled):
    http://alt-web.com/DEMOS/CSS-Horiz-menu-2.shtml
    Example 2 (multi-colored)
    http://alt-web.com/DEMOS/CSS-Multi-colored-drop-menu.shtml
    Nancy O.

  • Combining image and text in accordion content panel

    Hello,
    I'm having difficulty displaying image and text together within an accordion content panel.  What I need is a thumbnail photo of a staff member plus a short bio.  I've put a panel together so it displays as needed in Live View, but not in IE8, Foxfire8, or Chrome.  I'm using Dreamweaver 5.5, Spry 1.6.1, Windows 7.
    Here's the code for the panel that includes an image not displaying:
    <div class="AccordionPanel">
    <div class="AccordionPanelTab">Stan Swiercz, Training Manager</div>
    <div class="AccordionPanelContent">
    <div class = "PanelImage"> <img src="/images/StanSwiercz.jpg"/></div>
    Bio text goes here</div>
    </div>
    Here's a link to a test page (ignore funky color variations, still settling those).  The panel that is set to open should display an image floating left with text wrapping, as it does in Live View.
    http://cet-training.org/Test%20folder/people.html
    I''ve double-checked documentation, help, and done searches, but can't find any information about what should be an easy thing to do.  Any help out there?
    Thank you very much,
    George

    The location of the image is http://cet-training.org/Test%20folder/images/StanSwiercz.jpg (click the link to see the image)
    This is the markup from your document <img src="/images/StanSwiercz.jpg"/> which means that the image is located in the images folder which is located in the root directory.
    Hence the image cannot be found by your document.
    The following are possible solutions, please choose one only
    change the location of the images folder to reside in the root directory
    delete the leading slash from the link as in <img src="images/StanSwiercz.jpg"/>
    change the link to an absolute value as in <img src="http://cet-training.org/Test%20folder/images/StanSwiercz.jpg"/>
    Gramps

  • How to change bufferedImage to Image at Phone

    i transfer the buffered Image at a byte array format to phone, but i can't change the byte array to Image at the phone, how can i do that?

    Hi Jaime,
    Thanks is done .. 
    On dx650 phone background change is same procedure or different.
    File size is different i know but list.xml is same or different ?
    Or i can upload only one list.xml file just line add for dx650 phone.
    Thanks
    Afzal 

  • How to convert BufferedImage back to Image

    I have an Image from ImageIcon and i want to cut it using BufferedImage.getSubImage(...) and now from BufferedImage i want to turn it to Image again so that i can put in ImageIcon.
    Here is my code:
    URL img = new URL(location);
    ImageIcon imgIcon = new ImageIcon(img);
    Image image = imgIcon.getImage();
    //turn image into bufferedImage via graphic draw
    BufferedImage bi = new BufferedImage(..);
    Graphics g = bi.createGraphics();
    g.drawImage(image,0,0,null);
    bi.getSubImage(...);
    // how to turn bi back to Image newImage
    any ideas??

    More correctly, BufferedImage extends Image as Image is an abstract class and not an interface.
    Shaun

Maybe you are looking for

  • Adding variable to url

    Hi I have a list of website links which user can click on.. On click, I want to call a JSP (http://localhost:8080/abc/faces/urlprofile.jsp) which can display data related to the website. To do this, I want the website's url to be appended to my url i

  • File to RFC Error

    Hi,   I done File->RFC scenario. It was showing WAITING in Message Monitoring. But in CC Monitoring showing error like <b>No suitable sender agrement found</b>. Y it is showing like this? even I done Sender Agrement? thx and regards, Ansar.

  • Check name field with RegEx

    Hi, Regular Expression is something new to me, and I understand it in it's basic explanation form. Anyways, I have a table with a first name column, and a last name column. The table has over a million records, anyways, I started to do something, but

  • Arrangement of tabs in JTabbed Pane

    I am trying to design an UI with JTabbedPane with 12 tabs...and I want the WRAP_TAB_LAYOUT for this JTabbedPane...I am able to arrange 12 tabs in 2 rows by setting the width and height of the frame containing JTabbedPane....but when i run same progra

  • JDK - Time configuration for France

    Hi! I'm using GregorianCalendar class to get current date and time like above: GregorianCalendar today = new GregorianCalendar(); I'm located in Paris and the time I get is automatically converted to Greenwich Mean Time (so one hour less than the one