Java Image

Hai eveybody,
Can anyone tell me how to find out whether an image is too dark or bright in Java?
Regards,
Cochu.

Many thanks for your reply, and now I am clear about what to be done. But after applying pixel grabber , I am not getting the value in the format you said but getting values like 0:27. May be my code is not proper, I am giving the piece of code I am using below,
PixelGrabber pixelGrabber=new PixelGrabber(image, 0,0,width,height,false);
               try
                    pixelGrabber.grabPixels();
               catch (Exception e)
                    System.out.println("PixelGrabber exception");
               Object m_pixels=(Object)pixelGrabber.getPixels();
               byte[] pixels;
               pixels = (byte[])m_pixels;
Can you tell me where I did wrong?
Regards,
Cochu.

Similar Messages

  • Removing of standard java image in JOption Pane

    anyone can help to remove image(standard java image in JOption Pane).
    Looking forward for early response :)
    i tried to use (setIcon) method but i ecountered this error:
    Exception occurred during event dispatching:
    java.lang.NullPointerException
    at Sample.errorMsg(Sample.java:209)
    at Sample.check(Sample.java:177)
    at Sample.actionPerformed(Sample.java:124)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    just use JOptionPane.PLAIN_MESSAGE as a message type.

  • Standard java Image in JOption Pane

    Hello All!
    i am working on java application. i have to remove image(standard java image in JOption Pane).
    I'll be very thankfull if anybody can help me.
    Looking forward for early response :)

    i tried to use that method but i encountered this error:
    Exception occurred during event dispatching:
    java.lang.NullPointerException
    at LoginGUI.errorMsg(LoginGUI.java:209)
    at LoginGUI.check(LoginGUI.java:177)
    at LoginGUI.actionPerformed(LoginGUI.java:124)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Sour
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

  • Java Imaging API for Displaying CGM IMAGES along with Hotspot on Applets

    Are there any java imaging API's which displays the CGM Images on Applets? The CGM Image has Hotspot keys built in. So the Image displayed through Applet should also display the Hotspot keys.
    Also any Event Handler API's when the hotspot key is clicked?
    It would be great, if anyone can send any link regarding this subject

    You may want to try the jcgm library, though it doesn't support hotspots yet.
    [http://jcgm.sourceforge.net/]
    Philippe

  • A good book or a Tutorial about java Imaging

    Hello. I am new to java imaging and i was wondering if there is a good book or e-book or a tutorial that can help me learn about image processing. Do you have any suggestions? Thanx

    You can try this link ....
    hope it will help u a lot....
    http://www.javalobby.org/articles/ultimate-image/

  • Java imaging  raster bands

    Urgent,
    Do any1 konws the meaning of band and raster in java imaging?
    How to use raster to partition the pic and determine the location of a pixel at a picture?
    Thanks.

    any1 know?

  • InteractiveForm UI Element in Web Dynpro Java - Image not displayed on form

    Hello Experts,
    Using: NetWeaver Developer Studio 7.0.1_06; Adobe Livecycle Designer 8.1.
    I have an image "image.png" in my src/mimes/components/com.mm.InteractiveFormComp folder within my web dynpro java project.
    I load the image into my context in wdDoInit method in the comp controller:
    wdContext.currentContextElement().setImage("image.png");
    In the interactiveform I have an ImageField on the form and have set its properties as follows:
    Field - URL = http:[host]:[port]/webdynpro/dispatcher/InteractiveFormComp/src/mimes/components/com.mm.InteractiveFormComp/image.png
    Field - Embed Image Data = "checked"
    Binding - Default Binding = Image
    However, no image ever shows up on the form. I have also been through many threads in the forums but havent found a solution. Can anyone please assist me?
    Regards,
    MM.

    Hello,
    I tried using jpg and bmp. Didn't work.
    Any other suggestions?
    Regards,
    MM
    Solved it!
    Edited by: Marshall Mathers on Mar 9, 2011 9:53 PM

  • Confused about Java Image Processing APIs

    I'm working on a Java application to which I'd like to add some advanced visual effects. Specifically, I'd like to make the application UI "dissolve" away when a specific selection is made. (See this link - http://www.anfyteam.com/anj/deform/deform.html - for an example of the effect I'm trying to emulate.)
    I believe I know how to create this effect, but my main question has to do with how to actually accomplish it in Java. It seems that there are many different technologies that do the same thing--Java 2D and JAI among them--and many types of classes--BufferedImage, ImageProducer/ImageConsumer, etc.--that all do the same sorts of things.
    Can someone help me with this question: what is the most modern technique for doing something like this that would offer the best performance?
    Thanks very much!
    Greg

    Hi Greg.
    BufferedImage is pretty much the cream of the crop as far as working with images goes.
    The Producer/Consumer model, as I understand it, is an artefact from when Java was more applet-centric, and allows applications to use images as they are loading, under the assumption that they will load slowly.
    See these articles for more information:
    http://weblogs.java.net/blog/chet/archive/2003/08/bufferedimage_a.html
    http://weblogs.java.net/blog/chet/archive/2003/08/bufferedimage_a_1.html

  • Java image in html

    i hav created a jpg file using java...
    i need to use that file to display it in a table cell in html...
    how can i do that...

    sghai_7 wrote:
    i hav created a jpg file using java...
    i need to use that file to display it in a table cell in html...
    how can i do that...Use the HTML <img> element. There's a HTML tutorial at w3schools.com. If the image is not located in public webcontent, then you need to create a Servlet class as well. It's fairly simple: read the image as InputStream from disk and write it to OutputStream of response.
    For future servlet related questions better use the Java Servlets forum. This is the general Java Programming forum.

  • Java image library

    Hello:
    Can anybody help me to find a library in java to work with tiff?. I need to do some operations on the tiff, like resize, negative, put ellipses, circles and annotations over the image. I need an open source library or a low cost one.
    Thanks
    Sergio

    JAI, the Java Advanced Imaging library ought to work.
    It is available from sun, perhaps only as an early access, but search a little and you will find it.

  • Anyone know how to Save an Java Image to gif or png file?

    I'm trying to build a Map Edito for game, I want to import some images which and a lot of tiles in each of them. I want to cut each tile 24x24 out, then save it in an invidual file.
    Anyone know how to save to file? any easy way?
    I know there is somehthing call JPEGEncoding to save into jpeg...
    thanks!

    Java Advanced Imaging does it nicely, take a look.
    I do not remember the extact syntax right now, but have used it in the past.

  • Looking for Java Image Format converter

    hi,
    I am looking for an open-source site or so, which has Java code on converting different Image types eg. gif/jpeg etc. to PNG. I am building an application which needs to display images. It would be great to have a tool which takes the image and converts it to the PNG format.
    Can anyone help me out?
    cheers :)
    cleoppatra

    hi cleo. there is no tool you can patch into your source. there are two posibilities that i know of.
    1. take a look at the algorith for gif and jepg and chang it to png.
    2. send the link to a server, which you have to program, as a servlet, which will get the html page just as the midp would do, have a normal converter jpg -> png or gif -> png, see if what type of image it is, choose the right converter and convert the pic. format the text the way you want and then send it to the mobile phone. this will make most of the work be much faster since the mobile phone is very slow, and wont be very evectif on converting stuff.
    think about it.
    jeliel

  • Java Imaging on Pocket PC (Windows Mobile 2003)

    Hi all,
    I've got a problem concerning imaging on a pocket pc (HP IPAQ with an Intel PXA270 CPU). I have to extend an existing SWT application written with J2ME Personal Profil and IBM J9 runtime. The thing is, that I have to implement a certain imaging functionallty, namely I have to implement a function where you can rotate gifs/jpg images an arbitrary amount of grades around their center. After extensive searching I couldn't spot a java extension wich would include pocket pc support to do this rapidly.
    So I tried to do it "by hand", which means pixel by pixel (see attached code).
    But the problem I got now is a very weak performance. The rotation itself of a 600x600 gif consumes about 5800 ms which is definitly to heigh for the purpose I want to use it for. My questions now are:
    - Is there any imaging extension for java which I could use for this puropse on the pocket pc
    - If not: How could I improve the performance of the rotation function?
    I'd be very thankful for any tips & hints.
    static ImageData rotateFull(ImageData srcData, int grad) {
              int diagonal =
                   (int) Math.sqrt(
                        (srcData.width * srcData.width)
                             + (srcData.height * srcData.height));
              ImageData destData =
                   new ImageData(diagonal, diagonal, srcData.depth, srcData.palette);
              int x_adj, y_adj, x_new, y_new, pixel_data;
              int corrX = srcData.width / 2;
              int corrY = srcData.height / 2;
              int pixels = srcData.height * srcData.width;
              double bogen = (grad * Math.PI) / 180;
              float cos_winkel = (float) Math.cos(bogen);
              float sin_winkel = (float) Math.sin(bogen);
              for (int y = 0; y < (srcData.height); y++) {
                   for (int x = 0; x < (srcData.width); x++) {
                        x_adj = x - corrX;
                        y_adj = y - corrY;
                        x_new = (int) ((x_adj * cos_winkel) - (y_adj * sin_winkel));
                        y_new = (int) ((x_adj * sin_winkel) + (y_adj * cos_winkel));
                        pixel_data = srcData.getPixel(x, y);
                        destData.setPixel(
                             x_new + (destData.width / 2),
                             y_new + (destData.height / 2),
                             pixel_data);
              return destData;
         }

    Fellow regulars, please forgive the zombie thread: it's referenced in another thread, and it seemed the best place to put the following code.
    I've shown a number of intermediate steps en route to the best solution I can be bothered to post, which is the last of the rotate* methods. The next step, which would eliminate almost 4*sqrt(width*width+height*height) divisions, is to use Bresenham's line-drawing algorithm to work out the edges and then interpolate between them. However, to be frank, I couldn't be bothered. That's a lot of work, and probably means splitting the code into 9+ cases.
    One further optimisation which might be worth considering is to use the AWT ImageConsumer/ImageProducer model rather than SWT images. That would eliminate the awkward boxing/unboxing of the rasters, which is probably responsible for at least 10% of the time taken by rotateArray and subsequent.
    Profiling is always tricky. Comparing rotateTrueclip against rotateFull using different methods I measure it as taking as much as 133% of the time, or as little as 1%. The Bresenham version would certainly be faster than rotateTrueclip.
    I hope this proves useful both as code in its own right and as an example of some optimisation techniques.
    import org.eclipse.swt.events.*;
    import org.eclipse.swt.graphics.*;
    import org.eclipse.swt.widgets.*;
    public class RotationSandbox {
        private static final Display display=new Display();
        private final String title;
        private final Image image;
        public RotationSandbox(String title, Image image) {
            this.title=title;
            this.image=image;
        public RotationSandbox(String title, ImageData imagedata) {
            this(title, new Image(display,imagedata));
        public void run() {
            final Shell shell = new Shell(display);
            shell.addPaintListener(new PaintListener() {
                public void paintControl(PaintEvent event) {
                    // Draw the untainted image
                    event.gc.drawImage(image, 0, 0);
            shell.setText(title);
            shell.setSize(image.getImageData().width+20, image.getImageData().height+30);
            shell.open();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch()) {
                    display.sleep();
            image.dispose();
            display.dispose();
        static ImageData rotateFull(ImageData srcData, int grad) {
            int diagonal =
                (int) Math.sqrt(
                    (srcData.width * srcData.width)
                        + (srcData.height * srcData.height));
            ImageData destData =
                new ImageData(diagonal, diagonal, srcData.depth, srcData.palette);
            int x_adj, y_adj, x_new, y_new, pixel_data;
            int corrX = srcData.width / 2;
            int corrY = srcData.height / 2;
            int pixels = srcData.height * srcData.width;
            double bogen = (grad * Math.PI) / 180;
            float cos_winkel = (float) Math.cos(bogen);
            float sin_winkel = (float) Math.sin(bogen);
            for (int y = 0; y < (srcData.height); y++) {
                for (int x = 0; x < (srcData.width); x++) {
                    x_adj = x - corrX;
                    y_adj = y - corrY;
                    x_new = (int) ((x_adj * cos_winkel) - (y_adj * sin_winkel));
                    y_new = (int) ((x_adj * sin_winkel) + (y_adj * cos_winkel));
                    pixel_data = srcData.getPixel(x, y);
                    destData.setPixel(
                        x_new + (destData.width / 2),
                        y_new + (destData.height / 2),
                        pixel_data);
            return destData;
        // First change: iterate over destination pixels rather than source pixels.
        static ImageData rotateDest(ImageData srcData, int theta_deg) {
            int diagonal =
                (int) Math.sqrt(
                    (srcData.width * srcData.width)
                        + (srcData.height * srcData.height));
            ImageData destData =
                new ImageData(diagonal, diagonal, srcData.depth, srcData.palette);
            final int corrX = srcData.width / 2;
            final int corrY = srcData.height / 2;
            double bogen = (theta_deg * Math.PI) / 180;
            final float cos_winkel = (float) Math.cos(bogen);
            final float sin_winkel = (float) Math.sin(bogen);
            final int half_diag=diagonal>>1;
            for (int y=0; y<diagonal; y++) {
                for (int x=0; x<diagonal; x++) {
                    int x_new=x-half_diag, y_new=y-half_diag;
                    int x_adj=(int) ((x_new * cos_winkel) + (y_new * sin_winkel));
                    int y_adj=(int) (-(x_new * sin_winkel) + (y_new * cos_winkel));
                    int x_old=x_adj+corrX, y_old=y_adj+corrY;
                    if (x_old>=0 && y_old>=0 && x_old<srcData.width && y_old<srcData.height) {
                        destData.setPixel(x,y,srcData.getPixel(x_old,y_old));
            return destData;
        // Second change: replace multiplications with additions.
        static ImageData rotateIter(ImageData srcData, int theta_deg) {
            int diagonal =
                (int) Math.sqrt(
                    (srcData.width * srcData.width)
                        + (srcData.height * srcData.height));
            ImageData destData =
                new ImageData(diagonal, diagonal, srcData.depth, srcData.palette);
            final int corrX = srcData.width / 2;
            final int corrY = srcData.height / 2;
            double bogen = (theta_deg * Math.PI) / 180;
            final float cos_winkel = (float) Math.cos(bogen);
            final float sin_winkel = (float) Math.sin(bogen);
            final int half_diag=diagonal>>1;
            for (int y=0; y<diagonal; y++) {
                float x_adj=-half_diag*cos_winkel + (y-half_diag)*sin_winkel + corrX;
                float y_adj=half_diag*sin_winkel + (y-half_diag)*cos_winkel + corrY;
                for (int x=0; x<diagonal; x++) {
                    int x_old=(int)x_adj, y_old=(int)y_adj;
                    if (x_old>=0 && y_old>=0 && x_old<srcData.width && y_old<srcData.height) {
                        destData.setPixel(x,y,srcData.getPixel(x_old,y_old));
                    x_adj+=cos_winkel; y_adj-=sin_winkel;
            return destData;
        // Third change: eliminate those virtual method calls in favour of direct array indexing.
        static ImageData rotateArray(ImageData srcData, int theta_deg) {
            int diagonal =
                (int) Math.sqrt(
                    (srcData.width * srcData.width)
                        + (srcData.height * srcData.height));
            ImageData destData =
                new ImageData(diagonal, diagonal, srcData.depth, srcData.palette);
            final int corrX = srcData.width / 2;
            final int corrY = srcData.height / 2;
            double bogen = (theta_deg * Math.PI) / 180;
            final float cos_winkel = (float) Math.cos(bogen);
            final float sin_winkel = (float) Math.sin(bogen);
            final int half_diag=diagonal>>1;
            int[] src_raster=new int[srcData.width*srcData.height];
            srcData.getPixels(0,0,src_raster.length,src_raster,0);
            int[] dst_raster=new int[diagonal*diagonal];
            for (int y=0; y<diagonal; y++) {
                float x_adj=-half_diag*cos_winkel + (y-half_diag)*sin_winkel + corrX;
                float y_adj=half_diag*sin_winkel + (y-half_diag)*cos_winkel + corrY;
                for (int x=0; x<diagonal; x++) {
                    int x_old=(int)x_adj, y_old=(int)y_adj;
                    if (x_old>=0 && y_old>=0 && x_old<srcData.width && y_old<srcData.height) {
                        dst_raster[x+y*diagonal]=src_raster[x_old+y_old*srcData.width];
                    x_adj+=cos_winkel; y_adj-=sin_winkel;
            destData.setPixels(0,0,dst_raster.length,dst_raster,0);
            return destData;
        // Fourth change: use fixed-point rather than floating-point.
        static ImageData rotateFixpoint(ImageData srcData, int theta_deg) {
            int diagonal =
                (int) Math.sqrt(
                    (srcData.width * srcData.width)
                        + (srcData.height * srcData.height));
            ImageData destData =
                new ImageData(diagonal, diagonal, srcData.depth, srcData.palette);
            final int corrX = srcData.width / 2;
            final int corrY = srcData.height / 2;
            double bogen = (theta_deg * Math.PI) / 180;
            final int cos=(int)(65536*Math.cos(bogen));
            final int sin=(int)(65536*Math.sin(bogen));
            final int half_diag=diagonal>>1;
            int[] src_raster=new int[srcData.width*srcData.height];
            srcData.getPixels(0,0,src_raster.length,src_raster,0);
            int[] dst_raster=new int[diagonal*diagonal];
            for (int y=0; y<diagonal; y++) {
                int x_adj=-half_diag*cos + (y-half_diag)*sin + (corrX<<16);
                int y_adj=half_diag*sin + (y-half_diag)*cos + (corrY<<16);
                for (int x=0; x<diagonal; x++) {
                    int x_old=x_adj>>16, y_old=y_adj>>16;
                    if (x_old>=0 && y_old>=0 && x_old<srcData.width && y_old<srcData.height) {
                        dst_raster[x+y*diagonal]=src_raster[x_old+y_old*srcData.width];
                    x_adj+=cos; y_adj-=sin;
            destData.setPixels(0,0,dst_raster.length,dst_raster,0);
            return destData;
        // Fifth change: only iterate over the box we care about.
        // I've also done some incrementalising immediately, rather than defer to the
        // next version.
        static ImageData rotateTrueclip(ImageData srcData, int theta_deg) {
            int diagonal =
                (int) Math.sqrt(
                    (srcData.width * srcData.width)
                        + (srcData.height * srcData.height));
            ImageData destData =
                new ImageData(diagonal, diagonal, srcData.depth, srcData.palette);
            final int corrX = srcData.width / 2;
            final int corrY = srcData.height / 2;
            double bogen = (theta_deg * Math.PI) / 180;
            final int cos=(int)(65536*Math.cos(bogen));
            final int sin=(int)(65536*Math.sin(bogen));
            final int half_diag=diagonal>>1;
            final int wfix=srcData.width<<16, hfix=srcData.height<<16;
            int[] src_raster=new int[srcData.width*srcData.height];
            srcData.getPixels(0,0,src_raster.length,src_raster,0);
            int[] dst_raster=new int[diagonal*diagonal];
            int x_start=-half_diag*(cos+sin)+(corrX<<16)-sin;
            int x_end=x_start+diagonal*cos;
            int y_start=half_diag*(sin-cos)+(corrY<<16)-cos;
            for (int y=0; y<diagonal; y++) {
                x_start+=sin; x_end+=sin;
                y_start+=cos;
                int dxs=0, dxe=diagonal;
                // Clip to keep source x-coords in range.
                if (cos>0) {
                    if (x_start<0) dxs=(cos-1-x_start)/cos;
                    if (x_end>=wfix+cos) dxe=(wfix-x_start+cos-1)/cos;
                else if (cos<0) {
                    if (x_end<cos) dxe=(cos-x_start-cos+1)/cos;
                    if (x_start>=wfix) dxs=(wfix-x_start+cos-1)/cos;
                else if (x_start<0 || x_start>=wfix) continue;
                // Clip to keep src y-coords in range, taking into account the
                // changes already made to dxs and dxe.
                int y_adj=y_start-dxs*sin;
                final int y_end=y_start-dxe*sin;
                if (sin>0) {
                    if (y_end<-sin) dxe=(y_start+sin)/sin;
                    if (y_adj>=hfix) {
                        dxs=(-hfix+y_start+sin+1)/sin;
                        y_adj=y_start-dxs*sin;
                else if (sin<0) {
                    if (y_adj<0) {
                        dxs=(y_start+sin-1)/sin;
                        y_adj=y_start-dxs*sin;
                    if (y_end>=hfix-sin) dxe=(y_start-hfix+sin+1)/sin;
                else if (y_start<0 || y_start>=hfix) continue;
                int x_adj=x_start+dxs*cos;
                int doff=dxs+y*diagonal;
                for (int x=dxs; x<dxe; x++) {
                    int x_old=x_adj>>16, y_old=y_adj>>16;
                    dst_raster[doff++]=src_raster[x_old+y_old*srcData.width];
                    x_adj+=cos; y_adj-=sin;
            destData.setPixels(0,0,dst_raster.length,dst_raster,0);
            return destData;
        public static void main(String[] args) {
            ImageData orig=new ImageData(100,100,32,new PaletteData(0xff0000,0xff00,0xff));
            int[] raster=new int[100*100];
            int roff=0, col=0;
            for (int y=0; y<100; y++) {
                for (int x=0; x<100; x++) {
                    raster[roff++]=col;
                    col+=(1<<16);
                col=(col&0xff)+1;
            orig.setPixels(0,0,raster.length,raster,0);
            // For some reason I don't understand, not knowing SWT, I only appear able to
            // make one Display and one Shell per Display.
    //        new RotationSandbox("Original image",orig).run();
    //         ImageData dasu_rotate=rotateFull(orig,45);
    //         new RotationSandbox("Rotated with dasu's code",dasu_rotate).run();
    //         ImageData rotate_dest=rotateDest(orig,45);
    //         new RotationSandbox("Rotated iterating over dest pixels",rotate_dest).run();
    //         ImageData rotate_iter=rotateIter(orig,45);
    //         new RotationSandbox("Mul -> add",rotate_iter).run();
    //         ImageData rotate_array=rotateArray(orig,45);
    //         new RotationSandbox("Use raster arrays",rotate_array).run();
    //         ImageData rotate_fixpoint=rotateFixpoint(orig,45);
    //         new RotationSandbox("Use fixpoint arithmetic",rotate_fixpoint).run();
            ImageData rotate_trueclip=rotateTrueclip(orig,45);
            new RotationSandbox("Clip to rotated bounding box",rotate_trueclip).run();
    }

  • Re: Java Images and Threads prob Help!!

    Without going through it in detail the problem may be that you're doing the repaint which you hope will draw the image before the image has completed loading.
    Create your ImageIcon (loading the "xxxx.jpeg" files) during program initialisation. And check the load status of the icon, at least in a test version.

    I still cant get the reqd output. Only the 1st image is dispayed and when i click the second code, the 2nd image doesnt come(the first one does not disappear, and even when i click the code 1 i have to minimize/ maximize the screen, to get the image and after that it does not go for the s2nd image 2 come!! )
    Create your ImageIcon (loading the "xxxx.jpeg" files) during program >>initialisation. And check the load status of the icon, at least in a test version. How do u load the image during initialization??? and can ny1 plz tell me how to get the flashing threads with msgs????

  • Java image and byte[]

    I am having trouble writing and reading data from an image. I am using the following code to get the bytes for a picture.
    BufferedImage pic = ImageIO.read(new File(picture));
    WritableRaster writableRaster = pic.getRaster();
    DataBufferByte buffer = (DataBufferByte)writableRaster.getDataBuffer();
    byte[] picBytes = buffer.getData();After making some changes I would like to write the new bytes to a file. This seems to work as the new picture shows the changes when I look at it.
    File newFile = new File("C:/NewPic.jpg");
    ImageIO.write(pic,"jpg",newFile);However, when I try to read the newFile using the same method as above I do not get the same bytes. I am using the following code to print the bytes in hex to verify what they are.
    BufferedWriter out2 = new BufferedWriter(new FileWriter("pix2.txt"));
    for(int x=0; x<picBytes.length; x++)
    out2.write((Integer.toString(picBytes[x] & 0xff, 16).toUpperCase()+" "));
    }This produces:
    7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F
    7F 7F 7F 7F 7F 7F 7F 7F 7F 7F FF FF 7F FF FF FF
    for the bytes that I have made the changes to, and when I try to read from the newly created file I get:
    82 7F 7A 82 7F 7A 82 7E 7D 82 7E 7D 82 7D 7F 82
    7D 7F 82 7B 82 82 7B 82 AC A5 AC B4 AE B3 E0 DA
    but there is nothing wrong with the picture. Do I need to create a new BufferedImage before I save, or what could be causing this change?

    Hmmm... I'm not sure what you are doing or what your goal is, but are you aware that JPEGs tend to use a losey compression?

Maybe you are looking for