Converting awt to JAI image - please help!

My application needs to be able to create a JAI image and apply dither to it.
I got this working by using the fileload operator in JAI to load the image and convert it to a planar image but when I try to use the awtImage operator to convert the images to planar images it doesn't work.
I really don't understand why this is. The two methods are pratically identical.
This is the method that works and the error diffusion method
public void setDitherOp(String op, String picName,KernelJAI typeDither)
                      //operation name, parameter block
    srcImg = JAI.create("fileload", "Pics/"+picName);
    dataType = srcImg.getSampleModel().getDataType();
              //contains parameters to be used in dither operation
    pb = new ParameterBlock();
    pb.addSource(srcImg);
    layout = new ImageLayout();
    if(op=="ordered")
      orderedDither();
    else if(op=="error")
      errorDiffDither(typeDither);
public void errorDiffDither(KernelJAI typeDither)
      if(srcImg.getNumBands()==1)   //source image has one color band
        LookupTableJAI lut =new LookupTableJAI(new byte[] {(byte)0x00, (byte)0xff});
        pb.add(lut);
        pb.add(typeDither);
        byte[] map = new byte[] {(byte)0x00, (byte)0xff};
        ColorModel cm = new IndexColorModel(1, 2, map, map, map);
        layout.setColorModel(cm);
      else if(srcImg.getNumBands()==3)  //source image has three color bands
        pb.add(ColorCube.BYTE_496);  //add color cube to parameter block
        pb.add(typeDither);          //add error filter kernel
        System.out.println("error diffusion num bands is: "+srcImg.getNumBands());
      RenderingHints rhints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
      ditheredImage = JAI.create("errordiffusion", pb, rhints);
      if(ditheredImage==null)System.out.println("Dithered image is NULL");
This is the one that doesn't!
public void setDitherOp(String op, Image frameImage,KernelJAI typeDither)
    srcImg = JAI.create("AWTImage", frameImage);
    dataType = srcImg.getSampleModel().getDataType();
              //contains parameters to be used in dither operation
    pb = new ParameterBlock();
    pb.addSource(srcImg);
    if(srcImg==null)System.out.println("src image null in set dither op");
    /*if(srcImg!=null)
        ditheredImage = JAI.create("Invert", pb);
    layout = new ImageLayout();
    if(op=="ordered")
      orderedDither();
    else if(op=="error")
      errorDiffDither(typeDither);
public PlanarImage getDitheredImage()
    return ditheredImage;
  }The other really odd thing in the method that uses the awtImage operator is this:
if the code to invert the colours is executed it works fine. This must mean that it is creating the planar image from the awt image? I really don't see what the problem could be in that case because it uses the same error diffusion method after that.
Please help me with this - its part of a project thats due up in a few days and I really need to get this part working as soon as possible.
CurtinR

Hi morgair,
Thank you so much for answering!!
You're right - the FileLoad and awtImage operators return different types of objects.
FileLoad returns a RenderedImage
JAI.create("fileload", "Pics/"+picName);awtImage returns a PlanarImage. The sample model and color model are set according to the AWT image data.
srcImg = (PlanarImage)JAI.create("AWTImage", pbAwtOp);Also the error diffusion operation takes a renderedImage as a parameter. It says in the programming guide that the source image and the color map must have the same data type and number of bands. (That would explain why the method using fileLoad worked!)
How do I change the Planar image to a rendered imaage or specify the sample model and colour model of srcImg. I've been trying to do this but am going round in circles - there are descrepancies between the programmers guide and the API and I'm lost..
Any suggestions really really appreciated..

Similar Messages

  • Since upgrading to new version I do not know how to downloand and convert videos to DVD. Please help!

    Since updating to new vision of firefox I do not know know to download and convert videos to DVD. Please help!

    Reset the page zoom on pages that cause problems: <b>View > Zoom > Reset</b> (Ctrl+0 (zero); Cmd+0 on Mac)
    * http://kb.mozillazine.org/Zoom_text_of_web_pages
    You can use one of these extensions to set a default font size and page zoom on web pages:
    * Default FullZoom Level: https://addons.mozilla.org/firefox/addon/default-fullzoom-level/
    * NoSquint: https://addons.mozilla.org/firefox/addon/nosquint/

  • Podcast not showing up, neither is image Please Help!

    Hello,
    I'm sorry to start another thread when there are so many already with these problems but anything you could do to help me would be great.I have a music podcast called Rock Block
    http://rockblock.wordpress.com/
    http://feeds.feedburner.com/RockBlockPodcast
    I submitted my podcast to iTunes and it got put in the store. I am finally able to search for my podcast and get it to come up but whenever I try any kind of link i get a message saying "The item you have requested is not available in the US store"
    This is the link they gave me in the e-mail,
    http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?
    id=260388815
    I have also tried this: http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=http://feeds.fe edburner.com/RockBlockPodcast
    This: http://www.itunes.com/podcast?id=http://www.feeds.feedburner.com/RockBlockPodcas t
    and even this : itpc://feeds.feedburner.com/RockBlockPodcast
    But nothing works!
    It's been almost a week now and my image is also not showing up in the store either.
    Please help! Any suggestions would be greatly appreciated!
    Thanks

    Brian
    1 22fps sounds odd, perhaps a typo
    2 anything over 24 fps is not officially supported at that resolution
    3 is your source movie PAL/NTSC/24fps (29.97/25/24 fps) ? It's best not to convert as it can introduce stuttering between different frame rates
    4 Even if other parameters are ok, I'm not clear of the bitrate here which should be no more than 5000kbps for h264
    5 There was something in the iMovie 08 forum a while back when everyone was annoyed at the dumbing down when videos were looking soft and it was something to do with a deinterlacing flag not being set correctly on exports so only 1 field in a frame was showing making video look soft
    6 You are best setting all parameters for output manually as you are largely doing. Winston often recommends using 960x540 at whatever frame rate is needed for HD output as he feels there is little difference in quality
    7 Try converting short 20-30 sec clips only until you hit on a formula that works
    8 Don't give up - you'll get there, frustrating as it seems
    AC

  • How to Load External Images - Please Help!

    I have created a simple portfolio site. The buttons I created
    trigger separate frames. Could I not create a MC (Movie Clip) on
    each frame where the images now reside and then when the button is
    clicked (On "Click' Goto frame 1) for e.g. then the image would be
    loaded from an external folder named "Images" in my website?
    I am stumped as to how to set this up. Could someone please
    help me?
    Thanks

    Yes, you can do that. Which version of Flash and which
    version of Actionscript are you using?

  • Lightroom 4 contact sheet print crashes with over 12 images - Please help.

    Lightroom 4 consistently crashes every time I attempt to print a contact sheet containing over 12 images. Any less and the task is completed without error, any more and it inevitably crashes. Any thoughts?
    My workaround has been to export the images and create large contact sheets in Photoshop CS6, but this takes twice as long.
    This is a daily task and is significantly disrupting my workflow. Please help.
    Regards,
    Eliot

    So, I had this problem tonight after experiencing no problems with Lightroom 4 previously. I noticed that in the print dialog box, where you can select to print "all" the pages or a page range, the page range radial was highlighted and the defined page range was "7" to "7". I was only printing one image so I changed the print range to "1" to "1". And it did the trick. Crazy, eh?

  • I need to clean up the edges of an image, please help!!

    I stained a t-shirt and so to make one that was the same I scanned the image on it in order to later print it on a new t-shirt. I opened the scanned image on photoshop and removed the background, then I used the quick selection tool to select the colors (only has 2 colors) and to recolor it as the colors looked dull. The problem is, the quick selection tool didn't make a 'clean/smooth' selection so the edges are VERY bad and I don't know how to fix this! Please help!!
    I took a screenshot of the image I'm working on (so that you can have a better idea) and also a close up on the edges (it's like this in all of the image)

    It sounds like you want a vector image.
    One word:  Illustrator.  That's Adobe Illustrator.

  • Rating is being applied to EVERYTHING, not just the active image- please help.

    Seemingly out of nowhere a particular feature in LR stopped behaving the way it normally does for me.
    When I am in the Survey view (in the Library mode) and I have a number of images selected because I am trying to make my selections, it suddenly started applying my star rating to the entire set of say 10 images I have selected, and not just the one that is active. This is very strange- I have never seen it behave like this before. I can't remember hitting anything or changing any settings, but it just seemed to have started out of nowhere.
    It appears that if I go in and "manually" click on the star scale that appears below each of the images when you mouse over it, THEN it will apply the star rating to just that one image, but I can no longer just hit the "5" key and have just that one image that's active get the 5 star rating. It's doing it to everything.
    I've tried just restarting LR but that didn't change anything. Please please help, as this is really messing up my workflow.
    Thank you,
    Robyn
    I did visit the page below to confirm that it should indeed not be behaving in this manner:
    http://help.adobe.com/en_US/lightroom/using/WSEEE8FD0F-DFD8-47d0-A6FE-DD726E5F2E1A.html#WS 11A1E98C-3D8D-47b5-8335-4B9D8C3A5D36

    Rick,
    Thank you so much for your time and support!! Unfortunately I don't see that as an option . I'm including a screen shot of what I do see. Anything else you have to offer would be very much appreciated!
    thanks again!

  • Flickering-Image -----Please Help

    Pls help meI have one hand image. I am drawing polygon above each finger.
    Whenever the user clicks on particular finger, we are changing the color of that polygon.
    We are changing the colors of the fingers(polygons) based on the database value when some functionalty is invoked. We are updating this color in PaintComponent of JPanel. The colors are flickering some time.
    Please help.
    Thanks in Advance.
    code -------------
    class ImagePanel extends JPanel {
    Image img1,img2;
    URL imageUrl1,imageUrl2;
         int x,y;
         public ImagePanel() {
    create 10 polygons for 10 fingers
    setLayout(null);
         this.addMouseListener(new panelMouseListener(this));
    //this method creates the status panel
         void fillPoly() {
         //set the color of the fingers to green (when template is available).
              Graphics g=getGraphics();
              Graphics2D gg = (Graphics2D)g;
    //fetching the records from database and depending on records changing the color to green yellow and selected finger to red
                   if(fingerId==1)     {
                        gg.setColor(Color.red);
                        gg.fillPolygon(p[0]);
              } else if(fingerId==2) {
                   gg.setColor(Color.red);
                   gg.fillPolygon(p[1]);
    public void paintComponent(Graphics gg) {
    Graphics2D g = (Graphics2D)gg;
    super.paintComponent(g); //paint background
    int x1,y1;
         fillPoly();
    //left hand
    if(p[0].contains(x,y)) {
         //g.drawImage(img1, 0, 0, this);
         //g.drawImage(img2,110, 0, this);
         fingerId=1;
              msg="left pinkie finger";
              flag=true;
              showFingerImages(fingerId,flag);
              fillPoly();
         } else if(p[1].contains(x,y)) {
              //g.drawImage(img1, 0, 0, this);
              //g.drawImage(img2, 110, 0, this);
              fingerId=2;
         msg="left ring finger";
         flag=true;
         showFingerImages(fingerId,flag);
         }else {
              //g.drawImage(img1, 0, 0, this);
                   //g.drawImage(img2, 110, 0, this);
                   fingerId=0;
                   msg="Please Select The Finger";
         g.drawImage(img1, 0, 0, this);
         g.drawImage(img2,110, 0, this);
    class panelMouseListener extends MouseAdapter {
              ImagePanel ip;
              panelMouseListener(ImagePanel ip)
              { this.ip=ip;
         public void mousePressed(MouseEvent me) {
         x=me.getX();
         y=me.getY();
         //fillPoly();
         ip.repaint();

    I'm not sure you model is the best but, nevermind, pass the graphics as argument of the method fillPoly :
    class ImagePanel extends JPanel {
         Image img1,img2;
         URL imageUrl1,imageUrl2;
         int x,y;
         public ImagePanel() {
              setLayout(null);
              addMouseListener(new PanelMouseListener());
         //this method creates the status panel
         void fillPoly(Graphics2D g) {
              //set the color of the fingers to green (when template is available).
              //fetching the records from database and depending on records changing the color to green yellow and selected finger to red
              if(fingerId==1) {
                   g.setColor(Color.red);
                   g.fillPolygon(p[0]);
              else if(fingerId==2) {
                   g.setColor(Color.red);
                   g.fillPolygon(p[1]);
         public void paintComponent(Graphics gg) {
              Graphics2D g = (Graphics2D)gg;
              super.paintComponent(g); //paint background
              int x1,y1;
              fillPoly(g);
              //left hand
              if(p[0].contains(x,y)) {
                   //g.drawImage(img1, 0, 0, this);
                   //g.drawImage(img2,110, 0, this);
                   fingerId=1;
                   msg="left pinkie finger";
                   flag=true;
                   showFingerImages(fingerId,flag);
                   fillPoly(g);
              else {
                   if(p[1].contains(x,y)) {
                        //g.drawImage(img1, 0, 0, this);
                        //g.drawImage(img2, 110, 0, this);
                        fingerId=2;
                        msg="left ring finger";
                        flag=true;
                        showFingerImages(fingerId,flag);
                   else {
                        //g.drawImage(img1, 0, 0, this);
                        //g.drawImage(img2, 110, 0, this);
                        fingerId=0;
                        msg="Please Select The Finger";
                   g.drawImage(img1, 0, 0, this);
                   g.drawImage(img2,110, 0, this);
         final class PanelMouseListener extends MouseAdapter {
              public void mousePressed(MouseEvent me) {
                   x=me.getX();
                   y=me.getY();
                   repaint();
    }I hope this helps,
    Denis

  • AWT error on Solaris, please help

    Hello all,
    I have designed a class to convert any picture format to WBMP using Jimi via a web browser.
    The user specifies the file to convert on his computer and presses a OK button. Then, the file is converted and saved to
    the server.
    When running it on a windows computer, everything is ok. But I try to run it on my solaris box, I got the following error :
    Error: 500
    java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
         at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
         at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:59)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:120)
         at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:58)
         at sun.awt.motif.MToolkit.(MToolkit.java:57)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:120)
         at java.awt.Toolkit$2.run(Toolkit.java:512)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:503)
         at com.sun.jimi.core.Jimi.getImage(Jimi.java:334)
         at com.sun.jimi.core.Jimi.getImage(Jimi.java:323)
         at com.mcms.util.Convert2Wbmp.loadImage(Convert2Wbmp.java:62)
         at com.mcms.util.Convert2Wbmp.convert(Convert2Wbmp.java:110)
         at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:500)
         at org.apache.tomcat.core.Handler.service(Handler.java:223)
         at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:448)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:911)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:824)
         at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:152)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:438)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:505)
         at java.lang.Thread.run(Thread.java:484)
    Note that the 6000 port is open on my solaris server :
    6000/tcp open X11
    What should I do ?
    Here's the code, I hope we're allowed to post it ;) :
    ==================
    Convert2WBMP.java
    ==================
    import com.sun.jimi.core.Jimi;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.PixelGrabber;
    import java.io.*;
    import java.io.PrintStream;
    import java.util.EventObject;
    import java.util.StringTokenizer;
    * This handles an individual incoming request. It returns a bytes etc from remote server.
    * @version 1.0
    public class Convert2Wbmp extends Frame
    private static int width;
    private static int height;
    private static Image image;
    private static int buffer[];
    public Convert2Wbmp()
    private Image loadImage(String s, boolean flag)
    Image image1 = null;
    try
    if(flag)
    image1 = Jimi.getImage(s);
    else
    image1 = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource(s));
    MediaTracker mediatracker = new MediaTracker(this);
         mediatracker.addImage(image1, 0);
         mediatracker.waitForID(0);
    catch(Exception _ex)
         _ex.printStackTrace();
    return null;
    if(image1.getWidth(null) == -1 || image1.getHeight(null) == -1){
    return null;
    else
    return image1;
    private static Image loadImage(InputStream s)
    //System.out.println("now loading Image...");
    Image image1 = null;
    try
         image1 = Jimi.getImage(s);
         MediaTracker mediatracker = new MediaTracker(new Convert2Wbmp());
         mediatracker.addImage(image1, 0);
         mediatracker.waitForID(0);
    catch(Exception _ex)
         _ex.printStackTrace();
    return null;
    if(image1.getWidth(null) == -1 || image1.getHeight(null) == -1)
    return null;
    else
    return image1;
    private static void makeWBMP()
    if(image != null)
    buffer = new int[width * height];
    try
    PixelGrabber pixelgrabber = new PixelGrabber(image.getScaledInstance(width, height, 1), 0, 0, width, height, buffer, 0, width);
    pixelgrabber.grabPixels();
    catch(Exception exception)
         exception.printStackTrace();
    public static void convert(InputStream picSource,OutputStream target) throws Exception
    if(picSource != null)
         Image image1 = null;
         try
         image1 = loadImage(picSource);
         }catch(Exception e){ }
         if(image1 == null)
         System.out.println("Failed to load image!");
         return;
         image = image1;
         width = image1.getWidth(null);
         height = image1.getHeight(null);
         makeWBMP();
         try
         WBMP.save(buffer, width, height, 30, target);
         }catch (Exception e)
         e.printStackTrace();
    public static void main(String[] arg)
    try
    String target = "target.wbmp";
    String source = "source.jpg";
    Convert2Wbmp.convert( new FileInputStream( new File(source)), new FileOutputStream(target) );
    System.out.println("convertion finish!!");
    catch(Exception err )
    err.printStackTrace();
    ============
    WBMP.java
    ============
    import java.awt.*;
    import java.awt.image.MemoryImageSource;
    import java.io.*;
    public abstract class WBMP
    public WBMP()
    public static Image errorDiff(int ai[], int i, int j, int k, Color color, boolean flag)
    //System.out.println(" [WBMP]-----errorDiff");
    double ad[] = new double[i * j];
    for(int l = 0; l < i * j; l++)
    ad[l] = greypixel(ai[l]);
    double d = 42D;
    for(int i1 = 0; i1 < j; i1++)
    for(int j1 = 0; j1 < i; j1++)
    double d1 = ad[i1 * i + j1];
    if(ad[i1 * i + j1] > (double)k)
    ad[i1 * i + j1] = 255D;
    else
    ad[i1 * i + j1] = 0.0D;
    double d2 = d1 - ad[i1 * i + j1];
    if(j1 < i - 1)
    ad[i1 * i + j1 + 1] = ad[i1 * i + j1 + 1] + (8D / d) * d2;
    if(j1 < i - 2)
    ad[i1 * i + j1 + 2] = ad[i1 * i + j1 + 2] + (4D / d) * d2;
    if(i1 < j - 1 && j1 > 1)
    ad[((i1 + 1) * i + j1) - 2] = ad[((i1 + 1) * i + j1) - 2] + (2D / d) * d2;
    if(i1 < j - 1 && j1 > 0)
    ad[((i1 + 1) * i + j1) - 1] = ad[((i1 + 1) * i + j1) - 1] + (4D / d) * d2;
    if(i1 < j - 1)
    ad[(i1 + 1) * i + j1] = ad[(i1 + 1) * i + j1] + (8D / d) * d2;
    if(i1 < j - 1 && j1 < i - 1)
    ad[(i1 + 1) * i + j1 + 1] = ad[(i1 + 1) * i + j1 + 1] + (4D / d) * d2;
    if(i1 < j - 1 && j1 < i - 2)
    ad[(i1 + 1) * i + j1 + 2] = ad[(i1 + 1) * i + j1 + 2] + (2D / d) * d2;
    if(i1 < j - 2 && j1 > 1)
    ad[((i1 + 2) * i + j1) - 2] = ad[((i1 + 2) * i + j1) - 2] + (1.0D / d) * d2;
    if(i1 < j - 2 && j1 > 0)
    ad[((i1 + 2) * i + j1) - 1] = ad[((i1 + 2) * i + j1) - 1] + (2D / d) * d2;
    if(i1 < j - 2)
    ad[(i1 + 2) * i + j1] = ad[(i1 + 2) * i + j1] + (4D / d) * d2;
    if(i1 < j - 2 && j1 < i - 1)
    ad[(i1 + 2) * i + j1 + 1] = ad[(i1 + 2) * i + j1 + 1] + (2D / d) * d2;
    if(i1 < j - 2 && j1 < i - 2)
    ad[(i1 + 2) * i + j1 + 2] = ad[(i1 + 2) * i + j1 + 2] + (1.0D / d) * d2;
    for(int k1 = 0; k1 < i * j; k1++)
    int l1 = (int)ad[k1];
    if(!flag)
    if("1".equals(handlesinglepixel(l1, k)))
    ai[k1] = color.getRGB();
    else
    ai[k1] = Color.black.getRGB();
    } else
    if("1".equals(handlesinglepixel(l1, k)))
    ai[k1] = Color.black.getRGB();
    else
    ai[k1] = color.getRGB();
    return (new Canvas()).createImage(new MemoryImageSource(i, j, ai, 0, i));
    public static Image errorDiff2(int ai[], int i, int j, int k, Color color, boolean flag)
    //System.out.println(" [WBMP]-----errorDiff");
    char c = '\377';
    byte byte0 = 2;
    double ad[] = new double[i * j];
    for(int l = 0; l < i * j; l++)
    ad[l] = greypixel(ai[l]);
    int i1 = ((c + 1) * 2) / byte0;
    int j1 = c / (byte0 - 1);
    int k1 = (9 * c) / 32;
    int ai1[] = new int;
    for(int k2 = 0; k2 < i; k2++)
    ai1[k2] = k1;
    for(int l2 = 0; l2 < j; l2++)
    int i3 = (7 * c) / 32;
    int k3 = c / 32;
    for(int i4 = 0; i4 < i; i4++)
    int i2 = (int)ad[l2 * i + i4];
    i2 += i3 + ai1[i4];
    int l1 = (i2 / i1) * j1;
    if(l1 > c)
    l1 = c;
    ad[l2 * i + i4] = l1;
    i2 -= l1;
    int j2 = i2 >> 4;
    i3 = 7 * j2;
    ai1[i4] = 5 * j2 + k3;
    if(i4 > 0)
    ai1[i4 - 1] += 3 * j2;
    k3 = i2 - 15 * j2;
    for(int j3 = 0; j3 < i * j; j3++)
    int l3 = (int)ad[j3];
    if(!flag)
    if("1".equals(handlesinglepixel(l3, 30)))
    ai[j3] = color.getRGB();
    else
    ai[j3] = Color.black.getRGB();
    } else
    if("1".equals(handlesinglepixel(l3, 30)))
    ai[j3] = Color.black.getRGB();
    else
    ai[j3] = color.getRGB();
    return (new Canvas()).createImage(new MemoryImageSource(i, j, ai, 0, i));
    private static int greypixel(int i)
    int j = i >> 24 & 0xff;
    int k = i >> 16 & 0xff;
    int l = i >> 8 & 0xff;
    int i1 = i & 0xff;
    return (k + l + i1) / 3;
    public static String handlesinglepixel(int i, int j)
    //      System.out.println(" [WBMP]-----handlesinglepixel");
    int k = i >> 24 & 0xff;
    int l = i >> 16 & 0xff;
    int i1 = i >> 8 & 0xff;
    int j1 = i & 0xff;
    if((l + i1 + j1) / 3 > j)
    return "1";
    else
    return "0";
    public static Image open(String s)
    throws FileNotFoundException
         //System.out.println(" [WBMP]-----open");
    Image image = null;
    FileInputStream fileinputstream = new FileInputStream(s);
    try
    fileinputstream.read();
    fileinputstream.read();
    int i = readMultiByteInteger(fileinputstream);
    int j = readMultiByteInteger(fileinputstream);
    int ai[] = new int[i * j];
    int k = 0;
    for(int l = 0; l < j; l++)
    for(int i1 = 0; i1 < i / 8; i1++)
    int j1 = fileinputstream.read();
    String s1 = Integer.toBinaryString(j1);
    for(int l1 = 0; l1 < 8 - s1.length(); l1++)
    ai[k++] = Color.black.getRGB();
    for(int i2 = 0; i2 < s1.length(); i2++)
    if(s1.charAt(i2) == '0')
    ai[k++] = Color.black.getRGB();
    else
    ai[k++] = Color.white.getRGB();
    if(i % 8 > 0)
    int k1 = fileinputstream.read();
    String s2 = Integer.toBinaryString(k1);
    String s3 = "";
    for(int j2 = 0; j2 < 8 - s2.length(); j2++)
    s3 = s3 + '0';
    s2 = s3 + s2;
    for(int k2 = 0; k2 < i % 8; k2++)
    if(s2.charAt(k2) == '0')
    ai[k++] = Color.black.getRGB();
    else
    ai[k++] = Color.white.getRGB();
    fileinputstream.close();
    image = (new Canvas()).createImage(new MemoryImageSource(i, j, ai, 0, i));
    catch(Exception _ex)
         _ex.printStackTrace();
    try
    fileinputstream.close();
    catch(Exception _ex2) {_ex2.printStackTrace(); }
    return null;
    return image;
    public static int readMultiByteInteger(InputStream inputstream)
    throws IOException
    //System.out.println(" [WBMP]-----readMultiByteInteger");
    StringBuffer stringbuffer = new StringBuffer("");
    StringBuffer stringbuffer1;
    do
    stringbuffer1 = new StringBuffer(Integer.toBinaryString(inputstream.read()));
    int i = 8 - stringbuffer1.length();
    for(int j = 0; j < i; j++)
    stringbuffer1.insert(0, '0');
    stringbuffer.append(stringbuffer1.substring(1));
    } while(stringbuffer1.charAt(0) != '0');
    return Integer.parseInt(stringbuffer.toString(), 2);
    public static boolean save(int ai[], int i, int j, int k, OutputStream outputstream)
         //System.out.println(" [WBMP]-----save");
    try
    outputstream.write(0);
    outputstream.write(0);
    writeMultiByteInteger(outputstream, i);
    writeMultiByteInteger(outputstream, j);
    String s = "";
    for(int l = 0; l < j; l++)
    for(int i1 = 0; i1 < i; i1++)
    s = s + handlesinglepixel(ai[l * i + i1], k);
    if(s.length() == 8)
    outputstream.write(Integer.parseInt(s, 2));
    s = "";
    if(s.length() > 0)
    int j1 = 8 - s.length();
    for(int k1 = 0; k1 < j1; k1++)
    s = s + "0";
    outputstream.write(Integer.parseInt(s, 2));
    s = "";
    catch(NumberFormatException _ex)
    return false;
    catch(IOException _ex)
    return false;
    return true;
    public static Image threshold(int ai[], int i, int j, int k, Color color, boolean flag)
    int ai1[] = new int[i * j];
    int l = 0;
    for(int i1 = 0; i1 < j; i1++)
    for(int j1 = 0; j1 < i; j1++)
    if(!flag)
    if("1".equals(handlesinglepixel(ai[l], k)))
    ai1[l++] = color.getRGB();
    else
    ai1[l++] = Color.black.getRGB();
    } else
    if("1".equals(handlesinglepixel(ai[l], k)))
    ai1[l++] = Color.black.getRGB();
    else
    ai1[l++] = color.getRGB();
    ai = ai1;
    return (new Canvas()).createImage(new MemoryImageSource(i, j, ai1, 0, i));
    public static void writeMultiByteInteger(OutputStream outputstream, int i)
    throws IOException
    String s = Integer.toBinaryString(i);
    int j = s.length();
    int k = j / 7;
    if(j % 7 != 0)
    k++;
    int ai[] = new int[k];
    int l = j;
    for(int i1 = k - 1; i1 >= 0; i1--)
    StringBuffer stringbuffer = new StringBuffer("");
    for(int k1 = 0; k1 < 7; k1++)
    if(--l < 0)
    stringbuffer.insert(0, '0');
    else
    stringbuffer.insert(0, s.charAt(l));
    if(i1 == k - 1)
    stringbuffer.insert(0, '0');
    else
    stringbuffer.insert(0, '1');
    ai[i1] = Integer.parseInt(stringbuffer.toString(), 2);
    for(int j1 = 0; j1 < ai.length; j1++)
    outputstream.write(ai[j1]);

    Hi
    I am working on a project in which I have to perform a task some thing similar to bluemountain.com. the way, they give option to select a background image, then have to fill a form in which one type its message and then on preview, they can see an image having the text written on it.
    Now I am doing to do this thing using JIMI. So far, what I have done is, I was able to create a jpg file and write several text on different coordinates. But one thing I want to do is, I want to load an existing file and then write text on it. I have tried this code. public static void main(String[] ar)
    try
    Frame frame = new Frame();
    frame.addNotify();
    Image image = frame.createImage(100,30);
    Graphics graphic = image.getGraphics();
    graphic.setFont(new Font("Times New Roman",Font.BOLD,20));
    graphic.setColor(Color.black);
    graphic.drawString("Hi Buddy",10,20);
    graphic.drawString("Cool",50,25);
    Jimi.putImage("image/jpg",image,"try.jpg");
    frame.removeNotify();
    catch(Exception e)
    e.printStackTrace();
    This is the code which creates a new image whereas I want to load an existing image and then write text on it.
    I have already used this code in the upper code.
    Image image = Jimi.getImage("filename");
    But as response, I get the following error msg:
    java.lang.IllegalAccessError:
    getGraphics() only valid for images
    created with createImage(w, h)
    now this is the main problem when I am trying to do the stuff. I m kinda new into this stuff. I tried several things but no luck so far. I have seen that u have already worked on these kinda things so thought you might help me out to get the thing done. Please do reply me with some solution.
    Regards,
    Faisal

  • Word doc converted with gray shaded pages - please help!

    I am using Acrobat PDF version 9 and converting from within Word 2007 but all the pages in the converted pdf file are shaded gray and I can't add backgrounds etc.  I am using the default pdf settings.  Conversion from Excel works fine.  Can anyone help please?  I'm desperate! Thanks Robyn

    Hello Folks,
      You may think I am wired but believe me it works..
    I had the same problem as “RJBAT” all I did copy everything from the original DOC and paste it to a new one and then saved as PDF. TRY it!!
    Thanks

  • Bridge exe. Bad Image, Please help!

    My bridge program will not open. It had been working in the past, but now I get the message "Application or DLL:\Program FilesAdobe\Adobe Bridge CS4\libaray8n28.dll is not valid windows image.  Please check against your install diskette."  Do I need to uninstall and reinstall CS4? all the disks? what do I need to do? Any help is very much appreciated.  Thank you, Jan

    This is an old CS2 Tech note but at least it mentions libagli18n28.dll.
    http://kb2.adobe.com/cps/328/328349.html
    This may also help: http://pcsupport.about.com/od/findbyerrormessage/a/libagli18n28-dll-not-found-missing-erro r.htm
    Google is your friend!

  • Possible convert to Blackberry from Palm - please help with outlook questions

    I'm debating switching from a Palm Treo 800 (battery life is awful) to Blackberry Curve. I chose the Treo because of active sync with my work exchange server and ability to open Office documents.
    Currently, I sync my outlook mail, tasks & calendar with work, and my contacts & notes with my home computer. So if i follow your instructions for using BIS instead of BES (my employer only provides BES service for a carrier which is not mine ...), will I be able to sync manually with a cable to my work computer for  calendar & tasks and then to my home computer for contacts & notes?
    I have to decide THIS WEEK if I'm going to switch from Palm to Blackberry, so please hurry! The blackberry seems like it's a lot more fun than the Palm, and your support is much more extensive and user-friendly!

    Ok, so if both machines are Outlook based, I would not see a problem,
    You would need  2 DM programs one at work and one at home.
    For work you can specify sync for tasks and calendar, for home sync contacts and notes.
    Both calendars would have to be the Outlook calendar as default.
    You can the have the synced BB and would have the ability to backup on both machines, or better yet, back up on one machine to eliminate confusion. In case of failure, you have a backup of ALL data.
    You wouldn't have to convert anything because Outlook is fully compatible with the Desktop Manager.
    I don't see a problem.
    Thanks
    Click Accept as Solution for posts that have solved your issue(s)!
    Be sure to click Like! for those who have helped you.
    Install BlackBerry Protect it's a free application designed to help find your lost BlackBerry smartphone, and keep the information on it secure.

  • Hp pro 8500 keeps asking for maganta ink when it's already a new one, then loose image, please help

    HP PRO8500
    KEEPS ASKING FOR MAGANTA INK, THEN LOOSE IMAGE, I ALREADY REPLACED INK TWICE BUT ISSUE STILL PERSIST.
    PLEASE HELP

    Ok, finally got it fixed !
    Here's what was causing the issue, and what I did to fix it :
    I had free content in my iTunes download queue that I got from the "iTunes 12 days of Christmas" promotion, but the problem was that some of the items (two HD episodes) were too large to fit in my harddrive (I'm running low on free hd space) - so each time I was running iTunes I had to cancel the downloading of those items. On my iPhone, I was able to cancel the downloading once for all, but iTunes somehow wanted to try downloading them even if I deleted them. This was quite frustrating so I sent a mail to the support using the Express Lane feature on the support website, asking for thos items to be removed from my iTunes account - and tadaaaa ! Once a nice guy from Apple deleted them, my iPhone stopped asking for that stupid password !

  • Problem with remote rollover of images, please help.

    Hello,
    I got some great help yeserday on how to set up remote rollovers for a image gallery. It all works great except for when you have the curser in between the thumbnail images at bottom, the 1st image that I placed in large photo spot shows up. Any thoughts on how to fix this? Here is the page so you can look at the code. http://www.test.detarconstruction.com/homes/howard/howard.html
    Thank you so very much in advance for all your help
    Amy Sue

    You have added a "Mouse Exit" action to each of the thumbnails which always replaces the big photo with the startup image 'outside.jpg' each time you leave a thumbnail.
    (In source view you can see:
      onmouseout="changeImages('big_photo','outside.jpg');return true"
    for each of the thumbnails).
    If you simply remove all "Mouse Exit" actions the big image that belongs to the last touched thumbnail remains visible even if you leave the thumbnail and until you touch another one.
    This may be the effect you were searching for.

  • Scanner only scans partial image, please help!

    scanner not working right (HP all in one printer), when I scan from the HP device I get partial images saved into "scanner output", when I scan from the computer I get a full image with a decreased viewing field that I need to resize. Now, scanning from the computer it opens a window to save in "scanner output" which I do, the device scans, I see the image, but when I clear that box there are zero saved projects in "scanner output". I am so frustrated. I even lock the 8.5"x11" in the resize field but images/viewing fields are still partial. HELP! Any advice would be greatly appreciated.

    Hi
    Which HP AIO scanner do you have? I have the C4280. When using the Device Manager I choose>scan picture>scan to:PDF File (which I use most often)>accept>save as XX.>save to desktop.
    Try saving to Desktop so you're not searching all the time (been there, done that).
    Let me know how it goes.
    M.

Maybe you are looking for

  • Where can I get a logic board for a McBook Prp A1260

    Where is the best place to get a logic board for my A1260 MacBook Pro 15"?

  • Command line stuff

    For some reason I can't get my program to run with the command line. It says that it can't find the main method, but when I run it in JCreator it works perfectly. I set the path to "C:\Program Files\Java\jdk1.5.0_05\bin" Then I went to the directory

  • Install failure - damaged or incomplete

    Hello, I was attempting to use the Linotype Font Explorer and it crashed (which wasnt unusual).. unfortunately, when trying to restart the program, it demanded that I re-download the free ware to update. Upon downloading, I again attempted to mount t

  • Not working right. Reinstalled Windows XP Pro on my M10-S405 Laptop,

    I was given this laptop Toshiba Satelite Pro M10-S405 that was once owned by a school,with no cds. So after it started acting up, so I tried to reinstall Win Xp Pro using the Win Xp Pro cd's that came with my desktop. Then my coputer showed that my W

  • Different user or different database

    Hello everyone, we have oracle 10g server on win2008 64bit os, now we run one project and its data on the server. After a months a new big project will be run on the same server . So we must answer this important question? We can run new project data