Fitting a 75x75 image into a 75x75 rectangle?...

Hello everyone!
I'm making a map creator that draws a 75x75 tile (an image) onto the screen, where ever you click.
I also have some 75x75 rectangles drawn in a nested for-loop using the g.drawRect(x, y, width, height); method.
But I want it to place the tile at the exact x, y locations of whatever rectangle I click, so that it'll fill out the whole rectangle. - How can I achieve this?
Best regards,
Benjamin.

Alright, let me put it this way:
How can I make this method:
    private void drawRectangles(Graphics g){
        final int ROWS = getHeight() / 75;
        final int COLUMNS = getWidth() / 75;
        for(int i = 0; i < ROWS + 1; i++){
            for(int j = 0; j < COLUMNS + 1; j++){
                int x = j * 75;
                int y = i * 75;
                g.drawRect(x, y, 75, 75);
    }Make a java.awt.Rectangle object, around each rectangle drawn by g.drawRect(...); and put it in an array, so that when it comes to placing the tile I can just say:
for(Rectangle rectangle: rectangles){
    g.drawImage(..., rectangle.x, rectangle.y, ...);
}To draw the tile at the exact java.awt.Rectangle's x, y location? :)

Similar Messages

  • How to insert an image into lower third rectangle title?

    I'm creating a new title for news videos for a local newspaper's website.
    I've created a white lower third rectangle and I want an image of the newspapers logo to be inside of the white lower third rectangle.
    I'm trying to drag the image into the title workspace but it wont allow me to do so......
    How can I get this image of the newspapers logo inside of the white lower third rectangle?
    Thanks,
    Any help appreciated!
    Jonathan.

    Hi Dave,
    Great advice! That's working fine.
    But....my white lower third rectangle has a fill opacity of 88%. When I've inserted the newspaper's logo into this rectangle, obviously the logo (which is white with blue text) has an opacity of 100%. But when I lower the logo opacity to 88% I lose the logo's white, but also the actual text of the logo too which is a problem.
    So I'm now thinking, is it possible to lower fill opacity from left to right in my rectangle? If so, this would allow the left hand side of my rectangle to stay at 100% fill opacity, which would match the white fill of the newspapers logo, and I could gradually reduce the opacity as the rectangle goes right, fading out towards the end.
    Is it possible to use fill opacity in a left to right motion?
    Thanks Again!

  • How to Fit large size image into ScrollingImagepanel

    I am newbie to JAI.
    If the size of the image is large then how to fit it into scrolligImagePanel size?
    What is the method to be used to fit it?
    Your help is highly appreciated.
    thanks in advance

    Tom,
    What version of PrPro are you working with?
    Actually, MPEG-2 is not a good format/CODEC to use, as it is both heavily compressed, and is in GOP (Group of Pictures) structure. The version of PrPro, that you have, might well define the best format to use, and maybe even not need to convert.
    Unfortunately, the Live version of WMM will only Export to WMV, where the "non-Live," older version, can Export to DV-AVI, though only Type I, and not Type II.
    In general, for an SD Project, DV-AVI Type II is as good, as it gets.
    The Frame Size of your Project is a bit odd. What prompted you to chose that?
    Good luck, and let us know just a bit more.
    Hunt

  • Photoshop CC: Have a template that I moved image into.  Image is too small.  How do I resize the image while in the template?  Or must I go to original image file and resize there again and again until I get the right fit?

    I have a template that I am able to plug different pictures into at different times.  The problem is that when I plug an image into that template, I find that the image is either too big or too small.  Is there a way to plug the image into the template and resize the image (and not the template itself) OR will I have to go to the file with the original image and resize it there and then try to plug it in to the template to see if it fits------and if it does not fit, go back to the original file with the image and resize it again and see if that fits---and so on and so on...........?  I have tried the" image size" option but it's hit or miss------mostly miss!
    Thanks!

    Read up on Smart Objects. It looks like you have no idea as to how to create and use them.
    Jut create a Smart Object from the layer containing whatever it image it is that you are "plugging into your template".  But you do need to learn the application at its most basic levels.
    Photoshop is a professional level application that makes no apologies for its very long and steep learning curve.  You cannot learn Photoshop in a forum, one question at a time.
    Or is it possible that you don't even have Photoshop proper but the stripped-down Photoshop Elements?"
    If the latter is the case, you're in the wrong forum.  This is not the Elements forum.
    Here's the link to the forum you would want if you're working in Elements.:
    https://forums.adobe.com/community/photoshop_elements/content
    If you do have Photoshop proper, please provide the exact version number of that application and of your OS.
    (edited for clarification)

  • Correct workflow when inserting images into text, InDesign CS4

    Hi,
    I am new to InDesign and I have a problem regarding a really basic thing and I would be very grateful for help.
    I am writing an article which is about 10 pages long. It consists mostly of text. I have finished writing and now I want to add some illustrations with descriptions. I've already figured out it's best to insert images into the text frame so they behave as "anchored objects" and they move together with text when I add or delete something on previous pages. Now I would like to place TWO OR MORE images, one next to each other, in a line. This is a bit tricky but I created an object style with Position: Custom in "Anchored object options" and it works more or less fine. This works great but now it would be hard to add descriptions to these images that would still be anchored.
    So I created something different. I made an empty rectangle frame, a small text frame under it and grouped them. Then I placed it in my master text frame and basically did the same thing as for previously described images. Now I place the newly loaded image in the empty rectangular frame and add text in the empty text frame. BUT now I have problems with frame size for different-size images.
    What if I have a REALLY LONG article and want to add LOTS of images with decriptions that would be anchored in the text so I can edit previous pages? I can do this my way, but it's extremely uncomfortable and takes ages. Is there any comfortable, non-destructive workflow for doing such things?
    Sorry for my English.

    Hi,
    I would recommend following steps:
    Place one or more images
    Don't anchor them yet.
    Arange them (the images) relatively to each other, add a text frame and arrange them correct relatively to the images.
    Group images and text
    Copy (or cut) them into the clippboard
    Set the curser into the text where it should flow
    Paste it
    Adjust the anchored object (the group)
    You need to group several objects to anchor them together as one anchor.
    Further recommendation:
    For the images I would specify an object style for fitting, stroke, corner optione.
    For text frames I would specify an object style for text object options, like text offset, and used paragraph style, no boarder, etc.
    For the group I would spcify an object style which leaves above mentioned settings undefined (option field is grea or has a dash). But the anchored position of the whole group and text wrapping should be specified.
    Willi Adelberger

  • InDesign CS3 Scripting XML Import Multiple Images into same Text Frame

    I am having trouble importing multiple images into the same Text Frame using XML import. I imported 5 images into the text frame. However, all 5 images are laying on top of one another. Does anyone know if there is a way to have all images laying out like how Microsoft Word handles inline images, i.e., laying out next image to the right of previsous image in the same line and if there is not enough space left in the line, then wrap to next line. Thanks in advance. I understand I could use JavaScript to do post import processing, e.g, calculate the image size and place each images accordingly. But I am trying to see whether there is a way to do this without scripts.

    You can apply an object style to all anchored images by script. A text frame containing main flow should be selected.
    var doc = app.activeDocument;
    var textFrame =  app.selection[0];
    var rectangles = textFrame.texts[0].rectangles;
    if (rectangles.length > 0) {
         for (var i=0; i < rectangles.length; i++) {
              rectangles[i].appliedObjectStyle = doc.objectStyles.item("Cover");
    However, there is a better approach:
    Step 1
    Create place holders for a single "Book" element and format it as needed -- apply an object style to the cover.
    Step 2
    Import the xml file -- the placeholders are replaced with data from the 1st xml element
    Step 3
    Drag & drop the element containing all "Books" elements into the main flow -- all elements are placed and formatted the same way as in step 1.
    Finally, add a new page, click the overset text icon and autoflow text to add pages so that to fit all the text.
    Hope this helps.
    Kasyan

  • How do I turn an image into a transparency?

    Hi,
    There's a question I've seen asked dozens or hundreds of times, and I thought I found an answer a few years ago. I've since forgotten how to do it:
    Turn an image into a transparency.
    Now, the obvious solution is to set the layer to "multiply." Yes, this is the effect I want. However, I want the layer to be transparent instead.
    Another solution is to draw an image on a transparent layer. This works great, but only applies if I create the image from scratch. I want to convert an existing image.
    Another solution is multiple steps:
    1) Copy image
    2) Click "edit in quick mask mode."
    3) Paste image
    4) Exit quick mask mode.
    5) Invert selection.
    6) Ctrl+backspace to fill selection with black, on a blank transparent layer.
    Result? The image is now transparent! However, this converts the image to greyscale! Great for linework and text, terrible for photos or art!
    In an older version of Photoshop 7, I believe I got the following to work:
    A) Follow the previous steps 1-6, creating a layer with transparency
    B) Copy the original picture to a layer above the transparency
    C) Group the layer with the transparency layer below. (Note, grouping doesn't work the same any more.)
    D) The top layer provides the colors, but the bottom layer provides the transparency.
    E) It is too light, so you take the top layer, and maximize "saturation" 100%.
    F) Merge the two layers. It retains the transparency of the bottom layer, with the hue of the top layer.
    This no longer works, because I don't know how grouping layers works anymore.
    So, I need white pixels to be transparent. Black pixels to have zero transparency. Red pixels to have zero transparency. Etc.
    Meanwhile, grey pixels are solid black, but partly transparent. Pink pixels are solid red, but partly transparent.
    All pixels are 100% saturated, and the "lightness" is determined by how transparent they are.
    So, an analogy would be printing a photo on a transparency. I need to convert an image to a transparency.
    If the image/layer were overlaid on white, it would look exactly like the original photo.
    Does anyone know how to accomplish this? Mathematically, it's easy. But I don't know about any filter, process, or method to make the conversion using CS5.
    Thanks,
    Ben

    Hello!
    I hope that I understand what you need.
    (One could just put the image on a layer, and lower its opacity, but you seem to be looking for an effect in wich the tranparency is not the same for all pixels.)
    Try this:
    1) Turn your image image as a layer (double-click it if it is a background layer) [In order to add a mask]
    2) Select all, Copy (CTRL+a, CTRL+C)
    3) add a layer mask (click the rectangle with a circle in the bottom of the layers panel) [to be able to change transparency]
    4) target the mask [so that you can past an image in it] ALT+click the mask, paste the image.
    5) Invert the colors of the mask (CTRL+I) [in order for the white to be transparent and the black opaque].
    You now have a layer whose transparency is based on the lightness of the pixels.
    Hope that's what you are after!
    Pierre

  • How to import PDF image into Pages manuscript that is larger than the text bed margins

    How do I import a PDF image into a Pages book manuscript, whose dimensions are larger than the global text bed margins? Any imported PDF image is automatically shrunk to fit within the text bed. I know I can set up a single page with wider margins and a text bed within it, but I want the image to import to a page already within the manuscript sequence, where the text bed margins are set and constant.
    Larry Kettelkamp
    [email protected]

    By default it should be dragging in as a floating image and not part of the text.
    What version of Pages are you using?
    In Pages 5 this is:
    Format > Arrange > Object Placement > Stay on Page > Size > Original size
    Peter

  • Drag the image into target

    I need to drag the image like (banana.png) and drop that image into target(rectangle),target2(rectangle),etc. but I difficult to replace that target(rectangle) to be (banana.png) in drop event handler, Please help Me..
    this is my source code
    final Rectangle target = new Rectangle();
    target.setOnDragDropped(new EventHandler <DragEvent>() {
    @Override
    public void handle(DragEvent event) {
    System.out.println("onDragDrop");
    Dragboard db = event.getDragboard();
    if (db.hasImage()) {
    db.getImage(); //how to get the image (banana.png) and replace the target (rectangle) ?
    event.consume();
    });

    final Pane rectangleHolder = new Pane();
    final Rectangle rectangle = new Rectangle();
    rectangleHolder.getChildren().add(rectangle);
    // add rectangleHolder to the layout instead of rectangle...
    // and then
    if (db.hasImage()) {
      rectangleHolder.getChildren().setAll(new ImageView(db.getImage());
    }Depending on your layout, you may be able simply replace the rectangle in the existing layout without introducing the new Pane. You can always do something like
    ObservableList<Node> rectangleAndSiblings = ((Pane)rectangle.getParent()).getChildren();
    rectangleAndSiblings.set(rectangleAndSiblings.indexOf(rectangle), new ImageView(db.getImage()));but it doesn't need to be that complex.

  • I just really need to know... After desigining my UX, how do I go about adding the image into ADOBE FLASH BUILDER to script on top of it?

    I just really need to know... After desigining my UX, how do I go about adding the image into ADOBE FLASH BUILDER to script on top of it?
    Any and all advice is welcome.

    Do you have different versions of the graphic novel pages, or is there just one version of the page? If there is one version, can you crop into the page without losing anything important?
    I would guess that there is one version, and that cropping into the page will lose something important. If that's the case, here's how I would handle it:
    Make a stage that is 14:9. The size doesn't matter, but 1400x900 could be a good starting point.
    Put down a background texture that fits well with the look of the other images. Make that fill the 1400x900 stage.
    Place your page graphics so that they are within the center 1200x788 area of the stage.
    Set the stage scalemode to "noBorder".
    You now have a layout that will work on all devices, as narrow as iPad, and as wide as iPhone 5. All without any code. On the widest devices you'll see a bit of your background pattern to the left and right of the page graphic. On the narrowest devices you'll see a bit of background pattern above and below the page graphic. But you won't lose sight of anything important.

  • Crop bmp image into 2 pieces and 3 pieces

    Hi!
    1. I want to crop a bmp image into 2 pieces and show the two cop image in 2 picturebox.
    2. I want to crop a bmp image into 3 pieces and show theme in 3 picturebox.
    Can anyone help me?

    Hi,
    put three pictureboxes to a Form named Form1
    public Form1()
    InitializeComponent();
    //create an image
    Bitmap bmp = new Bitmap(1024, 768);
    //draw something to it
    using (Graphics g = Graphics.FromImage(bmp))
    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    g.Clear(Color.Green);
    g.FillEllipse(Brushes.Yellow, new Rectangle(0, 0, bmp.Width, bmp.Height));
    //and crop ionto the array
    Bitmap[] bmps = CropIntoThree(bmp);
    this.pictureBox1.SizeMode = this.pictureBox2.SizeMode = this.pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;
    if(bmps[0] != null)
    this.pictureBox1.Image = bmps[0];
    if(bmps[1] != null)
    this.pictureBox2.Image = bmps[1];
    if(bmps[2] != null)
    this.pictureBox3.Image = bmps[2];
    private Bitmap[] CropIntoThree(Bitmap bmp)
    Bitmap[] bmps = new Bitmap[3];
    //get a third of the width
    int third = (int)Math.Ceiling(bmp.Width / 3.0);
    for (int i = 0; i < 3; i++)
    //if the last third should be smaller (by 1 or 2 pixels, you could use the modulo operator here too)
    if (i * third + third > bmp.Width)
    third = bmp.Width - i * third;
    bmps[i] = bmp.Clone(new Rectangle(i * third, 0, third, bmp.Height), bmp.PixelFormat);
    return bmps;
    [And dont forget to Dispose the bitmaps when you do not need them anymore, e.g. in the FormClosing event.]
    Regards,
      Thorsten

  • How to insert an in-line image into a table cell using Pages on OS X?

    How can I insert an image into a table cell using Pages (OS X) without it becoming the cell background? I want it to be a regular in-line image, but can't figure out how to do this for the life of me. Thanks!

    Welcome to Discussions.
    To insert an image into a cell, select the cell, then go to the Graphics Inspector and from the Fill drop down choose Image Fill and then select then image you want. You can now select from a new drop down how you want the image to fit.
    Walt

  • How to clone one part of an image into another

    Is it possible in Aperture to clone one part of an image into another or as in windows fuse the photos together?
    Thanks

    This points directly to the difference between a digital image conversion and development program, and a graphics program.
    Development programs' tools adjust the color and luminance information in each pixel.  They do not (mostly) add any information to the pixels or to the image.
    Graphics programs are built around adding information to images (or blank canvases).  Rectangles, circles, text, other images -- these are all graphics elements which are combined to make a new image.
    Aperture is the former (and also a superb digital asset manager).
    The generalized workflow is this:
    Capture information using a digital camera
    Optimize that information (make the picture as good as possible) using an image development program
    Combine pictures and graphics elements to make new graphics using a graphics program
    There are many excellent graphics programs.  Photoshop is the best known and most used.

  • A Simple Question... inserting image into JTextPane...

    Well my problem is very simple (but not for me). Before I explain it, please take a look at a simple class...
    public class Window extends JTextPane {
        Window() {
            super();
        }// Window
        public void appendText(String s,Color col) throws BadLocationException {
            StyledDocument sd = getStyledDocument();
            SimpleAttributeSet attr = new SimpleAttributeSet();
            StyleConstants.setForeground(attr,col);
            sd.insertString(sd.getLength(),s,attr);
          *     THE POINT - what should I write here, please consult description followed by the class.
        } //appendText
    } //classThe appendText method simply appends the text in text pane with desired color. Now I want to know what should I write at point THE POINT so that at end of appended string an icon (suppose end.gif) is added and is displayed in text pane. Simple?
    Stay happy,
    fadee

    Dear Fadee,
    here is a small programe for inserting images into JTextPane;
    find this comment and start
    /*All Code In this Button Action*/if you need any thing feel free to tell me,
    i'm with you brother, i'll do my best :O)
    -Best regards
    mnmmm
    * Fadee.java
    * Created on June 7, 2002, 1:13 AM
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.color.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    * @author  Brother Mohammad, Cairo, Egypt.
    * @version
    public class Fadee extends javax.swing.JFrame {
        JTextPane   tp;
        JButton     b;
        StyledDocument sd;
        SimpleAttributeSet attr;
        public Fadee() throws BadLocationException {
            b = new JButton("Press");
            tp = new JTextPane();
            b.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    /*All Code In this Button Action*/
                    try {
                        sd = tp.getStyledDocument();
                        attr = new SimpleAttributeSet();
                        /*get default style*/
                        Style def = StyleContext.getDefaultStyleContext().
                                            getStyle(StyleContext.DEFAULT_STYLE);
                        /*add style for text default style*/
                        Style regular = tp.addStyle("regular", def);
                        StyleConstants.setFontFamily(def, "SansSerif");
                        StyleConstants.setAlignment(def, StyleConstants.ALIGN_CENTER);
                        StyleConstants.setForeground(def, Color.RED);
                        /*add style for icon create as many as icons you have
                         and don't forget to resize the photo at small size
                         to fit with font size*/
                        Style s = tp.addStyle("icon", regular);
                        StyleConstants.setAlignment(s, StyleConstants.ALIGN_JUSTIFIED);
                        StyleConstants.setIcon(s, new ImageIcon("d:\\My Photo.GIF"));
                        /*here is what user will see*/
                        sd.insertString(sd.getLength(), "Allah Akbar ", tp.getStyle("regular"));
                        sd.insertString(sd.getLength(), " ", tp.getStyle("icon"));
                    } catch (BadLocationException x) {
                        x.printStackTrace();
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(b, BorderLayout.NORTH);
            getContentPane().add(tp, BorderLayout.CENTER);
            setSize(500, 500);
            setVisible(true);
        public static void main(String args[]) {
            try {
                Fadee f = new Fadee();
            } catch (BadLocationException x) {
                x.printStackTrace();
    }

  • Wall decals over size.. functionality to cut image into piece on artboard ?

    1- I am doing wall decals, I am drawing a big tree (7 foot long). My vinyl roll size in 24 inches. Is there a functionality in Adobe Illustrator CS5.5 to split the image into section ready to cut ? My cutting software can do it but I want to do it in illustrator... is there a way ???
    2- I am not able to find information on how illustrator can help me to place the objects on the artboard (with spaces between each objects) to maximize the vinyl space available without have to place each object by hand one by one.
    Thanks Nancy

    This kind of stuff (vinyl cutting project setup) was a pain to do in Illustrator prior to its finally (literally decades late to the game) acquiring the ability to have more than one page in a file. It's still a pain comparitive to Adobe's other vector drawing program (FreeHand), due to Illustrator's still-yet-to-appear ability to draw to user-defined scale.
    This is how I routinely do it in FreeHand:
    1. Draw the whole design at a comfortable scale (ex: 1"=1') on a convenient page size (ex: tabloid, so I can print it on a desktop printer). Define spot color Swatches for each vinyl.
    2. When the design is done, add pages (one for each vinyl to be used) with either height or width the actual width of my vinyl (ex: 24"). Set ruler guides on each page to indicate what I consider a comfortable "maximum cut width" for the gripper/roller margin of my machine.
    3. Select all elements of a single vinyl color, duplicate them to one of the full-size pages. Do this for each vinyl.
    4. Scale the elements to actual size (ex: 1200%).
    5. For an element too large for the maximum cut width, place a pair of ruler guides separated by the amount of desired overlap (ex: .25").
    6. Duplicate the object in place. Use the Knife tool to slice the object along one of the guides. Delete the unwanted piece.
    7. Similarly cut the remaining (original) copy along the other guide. Delete the unwanted piece.
    8. Freely arrange (move and/or rotate) each of the pieces so as to maximize vinyl usage on each vinyl-specific page. Drag length of vinyl pages to fit final arrangement.
    9. Export the full-size pages only.
    10. Open the exports in my cutter driver software, and cut.
    I leave it to you to translate the same basic operations to Illustrator. Some of the reasons I still find Illustrator inferior for this:
    Still no support for user-defined ruler scales.
    Very unreliable snaps behavior at zooms.
    The infernal "Global" swatch designation.
    Pages interface (like many things) needlessly cumbersome compared to FreeHand's. (Separate "Artboard mode" is tedious for arranging Artboards, making page-specific guides, snapping Artboards to grid and to each other.)
    Inferior behaviors of Boolean path operations ("Pathfinders"). (Ex: converting compound paths to groups.)
    Inferior cutting tools (Ex: releasing compound of compound paths; failure to handle open, unfilled paths.)
    JET

Maybe you are looking for

  • How to store values in varrays and how to retrieve it ?

    hi i am using d2k. i can store values in nested tables but i can't store it on varrays. declare TYPE NAMEARRAY IS table of varchar2(40) index by binary_integer; NAM NAMEARRAY; TYPE SACARRAY  IS table of varchar2(30) index by binary_integer; SAC SACAR

  • Weird Pacman Error! [solved]

    Since last night, I've been getting this weird error when I run 'pacman -Syu' as root. What's going on? :: Synchronizing package databases... current 71.2K 143.5K/s 00:00:00 [#####################] 100% extra is up to date community 274.6K 339.7K/s 0

  • Upgrade from Solaris 8 (5.8) to 5.10 fails

    Hi everyone... Here is a curly one for the Sun gurus. I attempted to perform the upgrade from Sol 8 (Dec/02) to Sol 10 (from the CD/DVD Jan/06) and got all the way past the "Test Upgrade Profile". The initialize started after I clicked onto the gui "

  • J integra alternative

    Hey guys I need a solution for a problem. i need to access outlook from java to send mails from my app. i have tried jintegra and it works but i don't want to buy it. can anyone refer me to api's or tutorials that can help me accomplish the same thin

  • HISTORY MANAGE CHECK BOX

    HI MASTERS, WHY WE UUSE HISTORY MANAGE CHECK BOX IN ASSET MASTER, AND IN ASSET CLASS, I THINKING  IT IS USED FOR UPLOADING THE ASSETS TO ASSET HISTORY SHEET IS IT. PLEASE GIVE REPLY THIS , POINTS WILL B ADDED.