Image manipulating

hi, this is my problem:
i would like to be able read an image-file from the disk and i would like to scale it depending
on it's size... if it's to big i would like to make it smaller.. :) if it's possible it would be good
to be able to scale the image in both file-size and image-size.
is there any standard classes for this or does anyone know about any good packages?
would also be nice if anyone good give me a good example of the procedure.
thanx!
/Andy

yes this can be done here is some code tht will show you how to do it. you will need to replace the images files that are in the code with ones of your own.... Also you need to be aware that java only supports Jpg and gif's ...nothing else.
// Start of the code. Cut paste compile and run For what you want look for "varient "B" in the Code and // comment out one or the other and run you will see the difference. You must supply your own jpg's or
// gif's!!
* @version step2 of4
* @author Phil Ygnacio email: [email protected]
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class ButtonPanel extends JPanel
implements ActionListener
public ButtonPanel()
Certifications = new JButton( "photo", new ImageIcon("blueball.gif"));
ResumeButton = new JButton("Test 1", new ImageIcon("blueball.gif"));
CertificationsButton = new JButton("Test 2", new ImageIcon("blueball.gif"));
add(Certifications);
add(ResumeButton);
add(CertificationsButton);
Certifications.addActionListener(this);
ResumeButton.addActionListener(this);
CertificationsButton.addActionListener(this);
setBackground(Color.black);               // set first Backgrnd color
     image = Toolkit.getDefaultToolkit().getImage
("Phil_11kb.gif");               // Grab the image you need in current directory.
MediaTracker tracker = new MediaTracker(this); // P. 309 & 241
tracker.addImage(image, 0);
try { tracker.waitForID(0); }          // Wait to load completely. P. 309
catch (InterruptedException e) {}
public void actionPerformed(ActionEvent evt)
{ Object source = evt.getSource();
Color color = getBackground();
if (source == Certifications)
                    color = Color.yellow;
image = Toolkit.getDefaultToolkit().getImage
("Phil_11kb.gif");               // Grab the image you need in current directory.
MediaTracker tracker = new MediaTracker(this); // P. 309 & 241
tracker.addImage(image, 0);
try { tracker.waitForID(0); }                    // Wait to load completely. P. 309
catch (InterruptedException e) {}
               repaint();
else if (source == ResumeButton)
          {color = Color.blue;}
else if (source == CertificationsButton)
          {color = Color.red;}
setBackground(color);               // set second Backgrnd colors based on choice
public void setFonts(Graphics g)     // Set the fonts and the font characteristics
{ if (f != null) return;                    // Test for no Fonts set
f = new Font("SansSerif", Font.BOLD, 28);          // Initialize private Var's.
fi = new Font("Serif",
Font.BOLD + Font.ITALIC, 18);          // Initialize private Var's.
     fm = g.getFontMetrics(f);          // Get the font metrics of the set fonts. P. 289
fim = g.getFontMetrics(fi);
public void paintComponent(Graphics g)          // This is where the graphic is displayed
{ super.paintComponent(g);
Dimension d = getSize();                         // Size of the current Window frame.
int clientWidth = d.width;
int clientHeight = d.height;
int imageWidth = image.getWidth(this);
int imageHeight = image.getHeight(this);
g.drawImage(image, 240, 50, (imageWidth), (imageHeight), this);
// varient "B" P.307/312 no stretch ability
// g.drawImage(image, 0, 0, (clientWidth), (clientHeight), this);
// varient "B" with stretch ability
setFonts(g);
String s1 = "Hey!! Look at this!";     // Initialize strings
String s2 = "I can do ";
String s3 = " GRAPHICS NOW!!";
int w1 = fm.stringWidth(s1);     // fm is private and get stringWidth of (s1)
int w2 = fim.stringWidth(s2);
int w3 = fm.stringWidth(s3);
d = getSize();               // get size of current Window
int cx = (d.width - w1) / 2;
int cy = (d.height - fm.getHeight()) / 2
+ fm.getAscent();               // get Total height of string using this font
g.setFont(f);                    // set the fonts on the strings and print them
g.setColor(Color.red.brighter().brighter().brighter()); // see page 292 "TIP"
g.drawString(s1, (cx+15), cy);
cx += w1;
cx = (d.width - w1 - w2 - w3) / 2;
cy = (d.height - fm.getHeight()) / 2
+ fm.getAscent();               // get Total height of string using this font
g.setFont(fi);
g.setColor(Color.black); // see page 292 "TIP"
g.drawString(s2, (cx+185), (cy+30));
cx += w2;
g.setFont(fi);
g.setColor(Color.blue); // see page 292 "TIP"
g.drawString(s3, (cx+185), (cy+30));
private Font f;
private Font fi;
private FontMetrics fm;
private FontMetrics fim;
private Image image;
private JButton Certifications;
private JButton ResumeButton;
private JButton CertificationsButton;
class ButtonFrame extends JFrame
public ButtonFrame()
{ setTitle("Step Two Advanced Button Test");
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{ System.exit(0);
Toolkit tk = Toolkit.getDefaultToolkit();               // see page 273 Re: Toolkit
Dimension d = tk.getScreenSize();
int screenHeight = d.height;
int screenWidth = d.width;
setSize(screenWidth , screenHeight );          // see page top of P.273 for
setLocation(screenWidth/256, screenHeight/256 );      // why these parametes are used!!                                    // ... or you can use whole numbers
                              // to set the Loc
/* setSize(screenWidth / 2 , screenHeight / 2);          // see page top of P.273 for
setLocation(screenWidth / 4, screenHeight / 4);      // why these parametes are used!!                          // ... or you can use whole numbers
*/           // to set the Loc                                                  
Image img = tk.getImage("Tree1.gif");     // sets the conner graphic
setIconImage(img);
Container contentPane = getContentPane();
contentPane.add(new ButtonPanel());
public class StepTwoAdvancedButtonTest
public static void main(String[] args)
{ JFrame frame = new ButtonFrame();
frame.show();
// end of the code
PS
New Study group starting.... We will be using the text called:
"Core Java2 Volume 1 Fundamentals" and "Core Java2 Volume 2" for advanced programmers. We will all use the same text and examples to learn from. Anyone is welcome,..but if you want to ask questions you will need to have this specific text and this text only and we will be using the example code from it to learn from.
Students in school are welcome but you MUST have this text so that we can refer you to specific pages for help with your projects.
The group will be following the texts VERY closely, but it does not matter where in the text you are or at level of experience you are at....ALL THAT MATTER IS THAT YOU HAVE THE TEXT THAT THE GROUP IS USING....
For more info write Phil Ygnacio at [email protected]
come on by!!

Similar Messages

  • MBPro problems with image manipulation apps

    My MBPro 15" 2011 never gave me any problem and I gotta say I am quite happy with it running any kind of app, recently, very recently, it often hangs up and requires many restarts to log in again, sometimes the grey screen stays still forever, some other times the screen shows stripes along the apple logo but most of all any time I open an image manipulation software it hangs up and fans start spinning a lot, it happens with PhotoShop and iPhoto but not with LightRoom (which is a 64bit app), tried to start a flight sim (the only game I have on the computer which also runs in 64bit) but same effect and it bothers me big time to have to backup it all and reinstall from scratch, any suggestion for problem source to look after?
    thank you
    Giovanni

    Sounds like youre GPU is dead - symptoms match exactly. Check out the thread here - 2011 MacBook Pro and discrete graphics card.
    https://discussions.apple.com/thread/4766577?tstart=0

  • How to use the image manipulation palette to extract a part of an image

    How to use the image manipulation palette to extract a part of an image?I have a parent image from which i need to extract a certain sub part.can somebody pls help me on how to use this particular tool?
    Thanks

    Use the above snippet. You might need to convert the Image Type you are using with picture functions. The above snippet will give you good idea on how to achieve what you intend to.
    -FraggerFox!
    Certified LabVIEW Architect, Certified TestStand Developer
    "What you think today is what you live tomorrow"

  • Runtime image manipulation using Flash

    I would like to know if it's feasible to load an image (jpg,
    gif, bmp and such) into Flash and then let the user modify it in
    order to stretch, crop, adjusting contrast/brightness, removing
    "red-eyes". I'm not aware of any image manipulation libraries in
    Flash, which is why I'm asking this.

    well, here's the showResult method:
    /**showResultImage() creates and shows results of manipulating pixels[]*/
         public void showResultImage()  {
              int tempPixl;
              int postOpWidth = postOpPixels[0].length;
              int postOpHeight = postOpPixels.length;
              int[] tempPix = new int[postOpHeight * postOpWidth];
              for (int i=0; i<tempPix.length; i++)  {
                   tempPixl  = postOpPixels[i / postOpWidth][i % postOpWidth];
                   //create gray-level pixel. 0xFF makes it opaque.
                   tempPix[i] = 0xFF000000 | (tempPixl << 16) | (tempPixl << 8) | tempPixl;
              } //End of i loop thru postOpPixels
              resultImage = Toolkit.getDefaultToolkit().createImage(
                        new MemoryImageSource(postOpWidth,
                         postOpHeight, tempPix, 0, postOpWidth) );
              scrollResultImage.remove(resultImagePanel);
              resultImagePanel.remove(resultImageDisplay);
              resultIcon = new ImageIcon(resultImage);
              resultImageDisplay = new JLabel(resultIcon);
              resultImagePanel.add(resultImageDisplay);
              scrollResultImage.getViewport().add(resultImagePanel);
         } /*End of showResultImage()*/

  • CS3/CS4 - Image manipulation

    Hi,
    Im writing a plugin that should crop some images (jpg,png,tif) physically. Does the SDK provide image manipulation functions for doing so, or should I instead link with e.g., ImageMagick or Boost::GIL ?
    Kind regards Toke

    Follow IHierarchy to the actual image - it is a separate boss.
    Edit: I see you figured that out yourself.
    On the child you'll have ITransform etc.
    IPathGeometry might also be useful.
    Dirk

  • Image Manipulation is making green and pink thumbnails

    Using the coldfusion 8 image manipulation we are getting thumbnails that the colors are all green and pink.  This seems to only affect the thumbnails and not the larger resized images.  See screenshot for example.  Any ideas why this is happening or how to fix it?
    The functions being used are ImageWrite and ImageScaleToFit.

    <!--- Set some defaults used by each image type, unless you override them --->
    <cfparam name="jpgQuality" default=".8" />
    <cfparam name="defaultInterpolation" default="bicubic" />
    <cfparam name="defaultBackground" default="black" />
    <!--- Set values for each image type --->
    <cfparam name="thumbMaxWidth" default="" />  <!--- leave blank to allow any width (forced to size by height) --->
    <cfparam name="thumbMaxHeight" default="60" /> <!--- leave blank to allow any height (forced to size by width, above) --->
    <cfparam name="thumbQuality" default="1" />  <!--- number from 0 - 1, 1 being the best --->
    <cfparam name="thumbFixedSize" default="false" />  <!--- you MUST set both MaxWidth & MaxHeight to use FixedSize --->
    <cfparam name="thumbBackground" default="#defaultBackground#" />  <!--- color of background if fixed size is used --->
    <cfparam name="thumbInterpolation" default="#defaultInterpolation#" />  <!--- Interpolation method used for resizing (HUGE performance hit depending on what is used) --->
    <cfparam name="normalMaxWidth" default="476" />
    <cfparam name="normalMaxHeight" default="324" />
    <cfparam name="normalQuality" default="#jpgQuality#" />
    <cfparam name="normalFixedSize" default="true" />
    <cfparam name="normalBackground" default="#defaultBackground#" />
    <cfparam name="normalInterpolation" default="#defaultInterpolation#" />
    <cfparam name="zoomMaxWidth" default="670" />
    <cfparam name="zoomMaxHeight" default="380" />
    <cfparam name="zoomQuality" default="#jpgQuality#" />
    <cfparam name="zoomFixedSize" default="true" />
    <cfparam name="zoomBackground" default="#defaultBackground#" />
    <cfparam name="zoomInterpolation" default="#defaultInterpolation#" />
    <!--- Set values for folder paths and the watermark image --->
    <cfparam name="originalFolder" default="path to folder for original images" />
    <cfparam name="thumbFolder" default="path to folder for thumbnail images" />
    <cfparam name="normalFolder" default="path to folder for large images" />
    <cfparam name="zoomFolder" default="path to folder for large resized images" />
    <cfparam name="watermarkImage" default="" />
    <cfparam name="wmXPosition" default="50" />  <!--- value is a number from 0 - 100, 50 = centered --->
    <cfparam name="wmYPosition" default="65" />
    <cffunction name="genWatermarkImage">
        <cfargument name="ImageFile" required="true" />
        <cfargument name="MaxWidth" required="true" />
        <cfargument name="MaxHeight" required="true" />
        <cfargument name="StorePath" required="true" />
        <cfargument name="FixedSize" required="true" type="Boolean" />
        <cfargument name="Background" required="true" />
        <cfargument name="Quality" required="true" />
        <cfargument name="Interpolation" required="true" />
        <cfargument name="AddWatermark" required="true" type="Boolean" />
        <cfif IsImageFile(originalFolder & ImageFile)>
            <cfset original = ImageNew(originalFolder & ImageFile) />
            <cfset originalHeight = ImageGetHeight(original) />
            <cfset originalWidth = ImageGetWidth(original) />
            <cfset outfile = StorePath & ImageFile />
            <cfset watermark = ImageNew(watermarkImage) />
            <cfset ImageScaleToFit(original,MaxWidth,MaxHeight,Interpolation) />
            <cfset new_w = ImageGetWidth(original) />
            <cfset new_h = ImageGetHeight(original) />
            <cfif FixedSize>
                <cfset normal = ImageNew("",MaxWidth,MaxHeight,"rgb",Background) />
                <cfset ImagePaste(normal,original,int((MaxWidth-new_w)/2),int((MaxHeight-new_h)/2)) />
                <cfif AddWatermark>
                    <cfset ImagePaste(normal,watermark,( int(ImageGetWidth(normal)) - int(ImageGetWidth(watermark)) -3),( int(ImageGetHeight(normal)) - int(ImageGetHeight(watermark)) -3) )/>
                </cfif>
                <cfset ImageWrite(normal,outfile,Quality) />
            <cfelse>
                <cfif AddWatermark>
                    <cfset ImagePaste(original,watermark,( int(ImageGetWidth(normal)) - int(ImageGetWidth(watermark)) -3), (int(ImageGetHeight(normal)) - int(ImageGetHeight(watermark)) -3) )/>
                </cfif>
                <cfset ImageWrite(original,outfile,Quality) />
            </cfif>
        <cfelse>
            <cfreturn "Image file not an image!" />
        </cfif>
    </cffunction>
    <cfset thumbError = genWatermarkImage(Filename ,thumbMaxWidth,thumbMaxHeight,thumbFolder,thumbFixedSize,thumbBackground,thumbQuality,thu mbInterpolation,"false") />
    <!---One of the images this happened to is attached.  This problem doesn't happen everytime but when it does it is a large group of photos.--->

  • Aperture API to Call External Image Manipulation Program

    Does the Aperture API allow someone to write a plugin to call an external image manipulation program (the one I'm thinking about is command line only) for image manipulations that would then take the manipulated image back into the library as a version of the original?

    That should be possible, but you'd have to make sure that the remapped result was saved back into the same file that was sent to it, and that the command-line tool can cope with 16-bit images.
    By the way, are you using a PanoTools-variant or something else for the defishing?
    Ian

  • Intensity image manipulation

    I have an intensity image that displays correctly, but is rotated 45 degrees.  I have messed around in LabVIEW trying to get it to display correctly, but have ran out of ideas.  How would I go about manipulating the matrix of data in LabVIEW to rotate the data back to its original position?
    Thanks,
    Anthony

    Hello Anthony,
    Thanks for posting to the NI Discussion Forum. This example might just be what you are looking for!  Let me know how it goes-
    Travis M
    LabVIEW R&D
    National Instruments

  • Help Needed..Fingerprint Identification..Image Manipulation

    Norfolk State University Student (Help Needed):
    I'm working on Fingerprint Identification using image correlation and/or a feature-based approach.  First, Goal is to minimize the lines of the minutia so that they are one pixel thick.  What services does Labview offer that will help me accomplish this task??

    Hey Snakehead...,
    Have you tried improving your original image with better lighting, better camera, better lens, etc.? What image processing have you done already, or are you starting from scratch? I agree with AnalogKid in providing some sample images to the forum so we can get an idea of what you are working with. Have you performed any morphology processing on the image? Have you tried edge detection functions? There are numerous functions that NI provides with their NI Vision software that will help you process your image, it is just finding the right combination that is the toughest part. Last, if you do have the Vision software, I might suggest taking a look at the Vision concepts manual to get an idea of the different functions and their capabilities. Let us know what kind of images you are working with and what you have done so far, and last, what you would like to eventually see. Thanks, and have a great day.
    Regards,
    DJ L.

  • Image Manipulation

    A client came to me today, not knowing any form of coding, he
    asked me if for his front page, he could place the images anywhere
    he wanted in the article he submits to the front page, as in being
    able to click on an image and drag it to his liking within his
    textarea on the insert article form in his admin area.
    I told him that was probably not possible, but will remain
    optimistic on the subject until after some inquiries.
    At present, the site is a php/mysql database driven site,
    within the admin area, he is able to enter his text for the front
    page and upload an image to display with his text. The display of
    the entry on the front page displays in a dynamic repeat table,
    that obviously, displays in the same format for every entry.
    Back to the subject, are there any applications or ideas that
    may come close to fullfilling this clients request?

    > Back to the subject, are there any applications or ideas
    that may come
    > close
    > to fullfilling this clients request?
    To make sure I understand, he wants to be able to position
    the image
    anywhere on the page without knowing HTML? If that's the
    question, then the
    answer would be NO, I think.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "bombardos" <[email protected]> wrote in
    message
    news:e3glqd$ssp$[email protected]..
    >A client came to me today, not knowing any form of
    coding, he asked me if
    >for
    > his front page, he could place the images anywhere he
    wanted in the
    > article he
    > submits to the front page, as in being able to click on
    an image and drag
    > it to
    > his liking within his textarea on the insert article
    form in his admin
    > area.
    > I told him that was probably not possible, but will
    remain optimistic on
    > the
    > subject until after some inquiries.
    >
    > At present, the site is a php/mysql database driven
    site, within the admin
    > area, he is able to enter his text for the front page
    and upload an image
    > to
    > display with his text. The display of the entry on the
    front page
    > displays in
    > a dynamic repeat table, that obviously, displays in the
    same format for
    > every
    > entry.
    >
    > Back to the subject, are there any applications or ideas
    that may come
    > close
    > to fullfilling this clients request?
    >
    >

  • Cross-DOM API and/or Techniques for simple image manipulation

    Am I correct in assuming that Cross-DOM API calls presume the target application is running? That is, these calls are not out to a "shared" library so to speak, but actually communication between two running apps.
    Assuming that is the case, is there any way, within Bridge itself, to do simple manipulations on files, such as scaling, and file type conversion. Am I required to have photoshop running to do this?

    Not sure on which platform you are using, and hoping it is not for hires/hiquality purposes, but you could use one of the many engines, for example the AppleScript Graphic Core.
    If you want/have to use PhotoShop, for what I know it has to be running.
    Bye!

  • Image Manipulation from Java to browser

    Let me start by saying that I rarely ever post. I try only to do it after I scouring the internet and coming up empty-handed. I have a task that I think should be easy, but of course it is not.
    I have an Applet with a JPopupMenu which contains a "Print" JMenuItem. When the item is clicked I use JavaScript via LiveConnect to open a new browser window. My intention is to screen scrape the original page (parse the HTML) and replace any "<OBJECT>" tag with an image of what the Applet is currently showing.
    Why?
    Well, printing from browsers is buggy at best. I have to support many different OSs and many different versions of Netscape and IE. Some systems can print the HTML page with Applets just fine. Others can do OK and some just crash at the thought.
    How?
    The idea is that if I recreate a snapshot of the page in a new browser window with images replacing the Applets then the broweser can print that page just fine.
    Problem?
    I create a BufferedImage in my Applet. The problem comes when I want to tell JavaScript to write the image to the new HTML file. I have seen examples of how this would be done in theory. Has anyone done this?
    Background:
    I want to use NO server side technologies (i.e. Servlet/JSP) and I do not want to have to sign any files or request any special permissions.
    Is there another way to accomplish this goal???
    Even if you don't have a good answer, I would appreciate any comments on the matter.
    Eric

    Generate the image from that html page.What would be the best way to generate an image of the
    browser rendered page? This is another issue I have
    struggled with.Ok, using a JEditorPane it is possible to render a HTML Page. Like all other Swing components it inherits the paintComponent method from JComponent. Simply generate an offscreen image and get its graphics context. Now you can pass this Graphics object the paintComponent and you get an image of your HTML page.
    Just make sure your offscreen image has the correct size. I guess this information is available from the JEditorPane.
    Use a PixelGrabber to get the image data and scan itfor the area the
    default.gif is placed.How would you use the PixelGrabber to find, or scan,
    for a 'default.gif' or multiple 'default.gif's? This
    too is an issue I have tried to wrap my mind around.This is the tricky part of it. Using the PixelGrabber you should get an array of pixel values. If you iterate thru this array it should be possible to find the pixel values of the default.gif (at least, if you choose a colr for your default.gif that does not appear in your HTML page incliding the other images).
    Now you have to replace those pixels with the pixels you have generated for your applets.
    J&ouml;rg

  • Pixel by pixel image manipulation- java

    Hey guys, i need to write a bit of code that looks at 3 images, assesses which pixels in ALL 3 are grey, and then redraws a new image consisting of the old ones, but grey only showing where all 3 have grey.
    The inputs are mays with grey overlays, so therefore the output pixels should be the same UNLESS the pixel was grey in all 3.
    I know its to do with arrays but im not a very good programmer and i need to get this done. Ive written the rest of my program, is anyone able to write this simple code? My problem is that i dont really know how to create an image using an array, plus also i know the pixel colours are stored awkwardly too. Ive only been programming in java for 4 weeks!

    The BufferedImage class is really good at creating images from an array. I don't know what a may is, but if you had an array of integer values in the format {a, r, g, b, a ,r, g, b}, it would be as easy as this:
              BufferedImage b = new BufferedImage(5, 5, BufferedImage.TYPE_4BYTE_ABGR);
              b.getRaster().setPixels(0, 0, 2, 1, new int[] {128, 64, 32, 16, 128, 75, 50, 25});Hope this helps.

  • Examples of still image manipulation in Motion 2

    I'm trying to find a site or two which would show some
    of the ways Motion 2 allows you to quickly manipulate and add motion to still images.
    I've gone through the mac tutotials here at the APPLE site,
    but I'm not really seeing what I'm looking for.
    Can anybody suggest a site or two? Thanks.

    New Discussions ResponsesThe new system for discussions asks that after you mark your question as Answered, you take the time to mark any posts that have aided you with the tag and the post that provided your answer with the tag. This not only gives points to the posters, but points anyone searching for answers to similar problems to the proper posts.
    If we use the forums properly they will work well...
    Patrick

  • Problem with Image Manipulation

    I am trying to make two methods. One to give me a 2-dim array of Colors from an image so I can access the pixels with x, y coordinates. The other to take an array like that and give me an image. Following is my code:
    import java.awt.*;
    import java.awt.image.*;
    import java.util.*;
    import javax.swing.*;
    public class ImgManip extends Component
         public static void main(String args[]) {
              new ImgManip();
         public ImgManip() {
              Image image1;
              Image image2;
              Color colors[][];
              System.out.println("Initialized");
              image1 = getImg("city.gif", true);
              System.out.println("city.gif loaded");
              colors = getPixelColors(image1);
              System.out.println("Pixel Colors Retrieved");
              image2 = makeImage(colors);
              System.out.println("Pixel Colors made into Image");
              System.out.println("image1 equals image2 :");
              System.out.println(image1.equals(image2));
         public Image getImg(String img, boolean wait)
              Image retVal = createImage(100, 100);
              try {
              Toolkit toolkit = Toolkit.getDefaultToolkit();
              Image image = toolkit.getImage(img);
              MediaTracker m = new MediaTracker(this);
              m.addImage(image, 0);
              if(wait) m.waitForID(0);
              retVal = image;
              } catch (Exception e) {}
              return retVal;
         public Image getImg(String img)
              return getImg(img, true);
         public int[][] getPixels(Image image)
              int w = getWidth(image);
              int h = getHeight(image);
              int pixAr[] = new int[w * h];
              int coor[][] = new int[w][h];
              int i;
              int ii;
              try {
              new PixelGrabber(image, 0, 0, w, h, pixAr, 0, w).grabPixels();
              } catch (Exception e) {}
              for(i = 0; i < h; i++)
                   for(ii = 0; ii < w; ii++)
                        int pai = i * w + ii;
                        //System.out.println("w: " + w + " h: " + h + " i: " + i + " ii: " + ii + " pai: " + pai);
                        coor[ii] = pixAr[i * w + ii];
              return coor;
         public Color[][] getPixelColors(Image image)
              int coor[][] = getPixels(image);
              Color colors[][] = new Color[coor.length][coor[0].length];
              int i, ii;
              for(i = 0; i < coor.length; i++) {
                   for(ii = 0; ii < coor[0].length; ii++) {
                        colors[i][ii] = new Color(coor[i][ii]);
              return colors;
         public Image makeImage(Color colors[][])
              int w = colors.length;
              int h = colors[0].length;
              int pixArg[] = new int[w * h];
              int i;
              int ii;
              for(i = 0; i < h; i++) {
                   for(ii = 0; ii < w; ii++) {
                        pixArg[i * w + ii] = colors[ii][i].getRGB();
              return createImage(new MemoryImageSource(w, h, ColorModel.getRGBdefault(), pixArg, 0, w));
         public static int getWidth(Image image)
              return image.getWidth(null);
         public static int getHeight(Image image)
              return image.getHeight(null);
    makeImage() gives me the image from the array and getPixelColors gives me the array. It compiles and runs, but the test program won't work. In the constructor for ImgManip, it displays if image1 and image2 are equal. If the methods worked correctly, they would be, but I am getting that they are not. Can someone please tell me what I am doing wrong?

    A quick check will compare the properties of the two images such
    as width,height and any other simple property that you think is
    relevent.
    However, the only way to be sure they are the same is to first perform the
    quick check above then run through the images and compare the
    pixel values of both (effectivly find the difference between the two
    images).
    public static boolean areEqual(BufferedImage a, BufferedImage b)
      // same address so same image
      if((a!=null)&&(a==b)) return true;
      // perform fast check this can rapidly tell if the images are not the
      // same but cannot tell if they are the same
      if(!fastCheck(a,b))
        return false;
      }else
        //loop through the images comparing the values of each pixel
        for(int i=0;i<a.getWidth();i++)
          for(int j=0;j<a.getHeight();j++)
            if(a.getRGB(i,j)!=b.getRGB(i,j)) return false;
      return true;
    }where fastCheck is similar to
    protected static boolean fastCheck(BufferedImage a, BufferedImage b)
      if(a==null or b==null) return false;
      if(a.getWidth()!=b.getWidth()) return false;
      if(a.getHeight()!=b.getHeight()) return false;
      // put some other fast tests in here
      return true;
    }matfud

Maybe you are looking for

  • How to find min and max of a field from sorted internal table

    Hi, I have sorted Internal Table by field f1. How do I find max and min value of f1. For min value of f1 I am using, READ TABLE IT1 INDEX 1. IT1-F1 = MIN. Is this correct? And how do I find the max value of f1 from this table. Thanks, CD

  • Is there an app where it saves your photo shortly after onto the web/online after taking a picture?

    Is there an app where it saves your photo shortly after onto the web/online after taking a picture? In essense, I want to be able to take a picture with the stock camera app on the Iphone 4 and have it saved immediately online after...without hooking

  • Buffalo Linkstation works with all PC's but not iMac - With Airport Extreme

    Hi. I hope someone can help. Been at this for days, even AppleCare can't help.... We have a Buffalo linkstation hooked to a new Airport Extreme. All PCs can see it and view documents, iTunes, etc. My iMac cannot. Actually, I think it sees it but it's

  • Display is too big

    When I came in the plug on my monitor was loose and the screen was getting no power. I got the plug to power the monitor, but now the display is larger than before. Whereas a website used to fit on the screen, now it is too big and I have to scroll o

  • Cannot see users on other nodes

    Calendar users cannot see the users on other nodes.What should I do? <P> You may not have configured your node-to-node connections. Use Connect Nodes or uninode -edit. Your fully qualified domain name for your network exceeds 16 characters. Shorten y