How JPG or GIF Image open in MIDP?

How my j2me application can support jpg or gif image format. I have tested png file in midp 1.0 and its not support other than png format( im not sure about midp 2.0 does it support or not). I have seen lot of mobiles those support gif and jpg file formats. Does j2me applications on those mobile can support other image formats?
Plus it is possible that i can develop my own decoder for jpg or gif format. I know it possible, but im talking related to its processing power consumption. Or is there any third party api exist to support jpg or gif file format on midp. Please r

Here is the code snap that read image from a URL.. I have tested this code on localhost & two different pc on lan in emulator.. but not in actuall mobile... but i hope it will work...
Image image = null ;
DataInputStream httpInput = null ;
DataOutputStream httpOutput = null ;
HttpConnection httpCon = null ;
String url = "http://localhost:8080/images/picture.png"
try
httpCon = (HttpConnection)Connector.open(url);
int bufferSize = 512 ;
     byte byteInput[] = new byte[bufferSize] ;
     ByteArrayOutputStream imageBuffer = new ByteArrayOutputStream(1024*50);
     httpInput = new DataInputStream( httpCon.openInputStream() );
               System.out.println("Http-Input Connecting Establish Successfully");
               httpOutput = new DataOutputStream( httpCon.openOutputStream() );
               System.out.println("Http-Output Establish Successfully");
int size = 0 ;
// read all image data ....
     while ( ( size = httpInput.read( byteInput , 0 , bufferSize ) ) != -1 )
                    imageBuffer.write( byteInput , 0 , size ) ;
// get byte from buffer stream
          byte byteImage[] = imageBuffer.toByteArray();
               System.out.println("read byte " + byteImage.length );
     // convert byte to image ...
     image = Image.createImage( byteImage , 0 , byteImage.length );
     return image ;
     //return null ;
catch( IOException e )
               System.out.println("\nUnable to Perform Image IO Operation with Host");
     return null ;
....................................

Similar Messages

  • Convert jpg to gif images

    I make an application that create jpg images with jfree chart.
    But my client need the graphics in GIF format.
    I need:
    1. A conver program to pass from JPG to GIF format
    or
    2. A program to generate graphics (pie 3-d with texts) in GIF
    Someone likes help me?
    Thanks.
    MIGUEL ANGEL CARO
    [email protected]

    JFreeChart is open source, I'm sure you can get a Java GIF encoder library and wedge it into the JFreeChart API to make it create GIFs.
    Why does it need to be GIFs, though?

  • How to resize GIF images

    Hi
    I used acme.jar to wirte gif images to a local disk . i worked fine , but iam facing problem in resizing these images , when i resize these images i get black background color in tat images .. can any body help me regarding this.....
    thumbImage = scaleToSize(imageWidth, imageHeight, thumbImage);
    Graphics2D graphics2D = thumbImage.createGraphics();
    graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
         RenderingHints.VALUE_INTERPOLATION_BILINEAR);
         graphics2D.drawImage(image,0,0,     thumbWidth,thumbHeight,null);
    out = new BufferedOutputStream(new FileOutputStream(newFilePath));
    GifEncoder gife = new GifEncoder(image,out);     
    gife.encode();
    this is my code .....

    Following is my code:
    public final String dealFile(ActionMapping mapping,ActionForm form,
                   HttpServletRequest request) throws FileNotFoundException, IOException{
              GroupForm gForm = (GroupForm) form;
              ActionMessages errors = new ActionMessages();
              // retrieve the file representation
              FormFile file = gForm.getPictFile();
              if (file == null) {
                   errors.add("FileNeeded", new ActionMessage("error.photo.filenull"));
                   saveErrors(request, errors);
                   return "failure";
              // has the maximum length been exceeded?
              Boolean maxLengthExceeded = (Boolean) request
                        .getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
              if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) {
                   errors.add("maxLengthExceeded", new ActionMessage(
                             "error.photo.length"));
                   saveErrors(request, errors);
                   return "failure";
              // retrieve the file name
              String fileName = file.getFileName();
              // judge file type
              String fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
              if (!(fileType.equalsIgnoreCase("jpg")
                        || fileType.equalsIgnoreCase("jpeg")
                        || fileType.equalsIgnoreCase("gif") || fileType
                        .equalsIgnoreCase("png"))) {
                   errors.add("NotPict", new ActionMessage("error.photo.wrongformat"));
                   saveErrors(request, errors);
                   return "failure";
              Date date = new Date();
              Random r = new Random(date.getTime());
              // ������������
              String newFileName = request.getSession().getId() + r.nextInt(10000)
                        + "." + fileType;
              String filePath = null;
              String newFilePath = null;
              // the directory to upload to
              String uploadDir = servlet.getServletContext()
                        .getRealPath("/resources")
                        + "/groupphoto/" + DateUtil.asShortString(date)+"/";
              // prepare directory if not exists
              File dirPath = new File(uploadDir);
              if (!dirPath.exists()) {
                   dirPath.mkdirs();
              // retrieve the file data
              InputStream stream = file.getInputStream();
              // write the file to the file specified
              OutputStream bos = new FileOutputStream(uploadDir + newFileName);
              int bytesRead = 0;
              byte[] buffer = new byte[8192];
              while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
                   bos.write(buffer, 0, bytesRead);
              bos.close();
              buffer = null;
              filePath = dirPath.getAbsolutePath() + Constants.FILE_SEP
                        + newFileName;
              File _file = new File(uploadDir + newFileName);
              Image src = ImageIO.read(_file); // ����Image����
              int width = src.getWidth(null); // ����������
              int height = src.getHeight(null);// ����������
              // convert the picture to picture within 100x100 and save to a file with
              // prefix
              // 100x100_ for later listing purpose.
              newFilePath = dirPath.getAbsolutePath() +Constants.FILE_SEP
                        + "100x100_" + newFileName;
              int newWidth = 0;
              int newHeight = 0;
              int bigger = width <= height ? height : width;
              if (bigger > 100) {
                   if (width >= height) {
                        newWidth = 100;
                        newHeight = height * 100 / width;
                   } else {
                        newHeight = 100;
                        newWidth = width * 100 / height;
                   ImageUtil.convert(filePath, newFilePath, newWidth, newHeight);
              // close the stream
              stream.close();
              _file = null;
              src = null;
              dirPath = null;
              String url = request.getContextPath() + "/resources" + "/groupphoto/"
              + DateUtil.asShortString(date)+"/"+ "100x100_" + newFileName;
              return url;          
         }

  • How to set gif image as wallpaper in Nokia s60v3 m...

    Hi, I am using N79 and i want set gif image as wallpaper.when i am trying to set a gif image as wallpaper no animation is coming on standby screen
    How to set gif wallpaper on standby screen with animation

    Not sure but you may have to install this application
    http://www.mobidhoom.com/anim-sprite-lite-v233s60v3/
    Try and give your feedback..
    --------------------------------------------------​--------------------------------------------------​--------------------------------------------------​--If you find this helpful, pl. hit the White Star in Green Box...

  • How to Print GIF image in XML RTF Report

    Hi All,
    I have one requirement like to print the GIF image in Oracle Report.
    The report is an XML Report.
    The image file stored in database, the table is fnd_attached_docs_form_vl.
    select distinct file_name from fnd_attached_docs_form_vl
    Front end Navigation ----->
    view -----> Attachments
    Now i need to get the image from there and print it report.
    Can you pls help me.
    Regards
    Venu

    Hi,
    I didn't tried that scenario as my report is not a Non-XML Report.
    And my report is XML Report.
    Regards
    Venu

  • How to insert GIF images in Blogs

    I am able to insert GIF images in to blogs... but its not playing .. only static..
    Any help..
    Thanks in advance..
    Regards,
    Mahesh

    Yes.. Its working perfect. (Sorry Jyoti sir for copy-paste)

  • Tiger Mail--How do I make a jpg or gif image into a clickable link?

    I'm trying to include a little banner graphic in outgoing email messages that will link to my blog when clicked. Tried doing this in imageready and it didn't seem to work right. I know this is very simple in Leopard Mail but still doing Tiger over here.
    I've searched all over and really cannot find the proper way to do this.
    Thanks!

    Might try this How To: Make an HTML Email Signature For Apple Mail...
    http://gatheringinlight.com/2007/12/03/how-to-make-an-html-email-signature-for-a pple-mail/
    And a sample Source code...
    http://www.box.net/shared/pvfvfly9nl

  • How To Fade In a JPG or GIF Image using Inspector Build-In or Action

    Inspector doesn't seem to have any Build-In or Action that allows me to FADE IN an image.
    There only seems to be an Opacity Action that allows a FADE OUT.
    This seems like kind of a software design oversight. Am I missing something in Keynote?

    The Dissolve transition can be used for either/both a fade-in or a fade-out.
    ... but by now you already know that.
    Message was edited by: Brie Fly

  • Load, crop and saving jpg and gif images with JFileChooser

    Hello!
    I wonder is there someone out there who can help me with a applic that load, (crop) and saving images using JFileChooser with a simple GUI as possible. I'm new to programming and i hope someone can show me.
    Tor

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.filechooser.*;
    import javax.swing.filechooser.FileFilter;
    public class ChopShop extends JPanel {
        JFileChooser fileChooser;
        BufferedImage image;
        Rectangle clip = new Rectangle(50,50,150,150);
        boolean showClip = true;
        public ChopShop() {
            fileChooser = new JFileChooser(".");
            fileChooser.setFileFilter(new ImageFilter());
        public void setClip(int x, int y) {
            clip.setLocation(x, y);
            repaint();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(image != null) {
                int x = (getWidth() - image.getWidth())/2;
                int y = (getHeight() - image.getHeight())/2;
                g2.drawImage(image, x, y, this);
            if(showClip) {
                g2.setPaint(Color.red);
                g2.draw(clip);
        public Dimension getPreferredSize() {
            int width = 400;
            int height = 400;
            int margin = 20;
            if(image != null) {
                width = image.getWidth() + 2*margin;
                height = image.getHeight() + 2*margin;
            return new Dimension(width, height);
        private void showOpenDialog() {
            if(fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
                File file = fileChooser.getSelectedFile();
                try {
                    image = ImageIO.read(file);
                } catch(IOException e) {
                    System.out.println("Read error for " + file.getPath() +
                                       ": " + e.getMessage());
                    image = null;
                revalidate();
                repaint();
        private void showSaveDialog() {
            if(image == null || !showClip)
                return;
            if(fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
                File file = fileChooser.getSelectedFile();
                String ext = ((ImageFilter)fileChooser.getFileFilter()).getExtension(file);
                // Make sure we have an ImageWriter for this extension.
                if(!canWriteTo(ext)) {
                    System.out.println("Cannot write image to " + ext + " file.");
                    String[] formatNames = ImageIO.getWriterFormatNames();
                    System.out.println("Supported extensions are:");
                    for(int j = 0; j < formatNames.length; j++)
                        System.out.println(formatNames[j]);
                    return;
                // If file exists, warn user, confirm overwrite.
                if(file.exists()) {
                    String message = "<html>" + file.getPath() + " already exists" +
                                     "<br>Do you want to replace it?";
                    int n = JOptionPane.showConfirmDialog(this, message, "Confirm",
                                                          JOptionPane.YES_NO_OPTION);
                    if(n != JOptionPane.YES_OPTION)
                        return;
                // Get the clipped image, if available. This is a subImage
                // of image -> they share the same data. Handle with care.
                BufferedImage clipped = getClippedImage();
                if(clipped == null)
                    return;
                // Copy the clipped image for safety.
                BufferedImage cropped = copy(clipped);
                boolean success = false;
                // Write cropped to the user-selected file.
                try {
                    success = ImageIO.write(cropped, ext, file);
                } catch(IOException e) {
                    System.out.println("Write error for " + file.getPath() +
                                       ": " + e.getMessage());
                System.out.println("writing image to " + file.getPath() +
                                   " was" + (success ? "" : " not") + " successful");
        private boolean canWriteTo(String ext) {
            // Support for writing gif format is new in j2se 1.6
            String[] formatNames = ImageIO.getWriterFormatNames();
            //System.out.printf("writer formats = %s%n",
            //                   java.util.Arrays.toString(formatNames));
            for(int j = 0; j < formatNames.length; j++) {
                if(formatNames[j].equalsIgnoreCase(ext))
                    return true;
            return false;
        private BufferedImage getClippedImage() {
            int w = getWidth();
            int h = getHeight();
            int iw = image.getWidth();
            int ih = image.getHeight();
            // Find origin of centered image.
            int ix = (w - iw)/2;
            int iy = (h - ih)/2;
            // Find clip location relative to image origin.
            int x = clip.x - ix;
            int y = clip.y - iy;
            // clip must be within image bounds to continue.
            if(x < 0 || x + clip.width  > iw || y < 0 || y + clip.height > ih) {
                System.out.println("clip is outside image boundries");
                return null;
            BufferedImage subImage = null;
            try {
                subImage = image.getSubimage(x, y, clip.width, clip.height);
            } catch(RasterFormatException e) {
                System.out.println("RFE: " + e.getMessage());
            // Caution: subImage is not independent from image. Changes
            // to one will affect the other. Copying is recommended.
            return subImage;
        private BufferedImage copy(BufferedImage src) {
            int w = src.getWidth();
            int h = src.getHeight();
            BufferedImage dest = new BufferedImage(w, h, src.getType());
            Graphics2D g2 = dest.createGraphics();
            g2.drawImage(src, 0, 0, this);
            g2.dispose();
            return dest;
        private JPanel getControls() {
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1.0;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            panel.add(getCropPanel(), gbc);
            panel.add(getImagePanel(), gbc);
            return panel;
        private JPanel getCropPanel() {
            JToggleButton toggle = new JToggleButton("clip", showClip);
            toggle.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    showClip = ((AbstractButton)e.getSource()).isSelected();
                    repaint();
            SpinnerNumberModel widthModel = new SpinnerNumberModel(150, 10, 400, 1);
            final JSpinner widthSpinner = new JSpinner(widthModel);
            SpinnerNumberModel heightModel = new SpinnerNumberModel(150, 10, 400, 1);
            final JSpinner heightSpinner = new JSpinner(heightModel);
            ChangeListener cl = new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    JSpinner spinner = (JSpinner)e.getSource();
                    int value = ((Number)spinner.getValue()).intValue();
                    if(spinner == widthSpinner)
                        clip.width = value;
                    if(spinner == heightSpinner)
                        clip.height = value;
                    repaint();
            widthSpinner.addChangeListener(cl);
            heightSpinner.addChangeListener(cl);
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(2,2,2,2);
            gbc.weightx = 1.0;
            panel.add(toggle, gbc);
            addComponents(new JLabel("width"),  widthSpinner,  panel, gbc);
            addComponents(new JLabel("height"), heightSpinner, panel, gbc);
            return panel;
        private void addComponents(Component c1, Component c2, Container c,
                                   GridBagConstraints gbc) {
            gbc.anchor = GridBagConstraints.EAST;
            c.add(c1, gbc);
            gbc.anchor = GridBagConstraints.WEST;
            c.add(c2, gbc);
        private JPanel getImagePanel() {
            final JButton open = new JButton("open");
            final JButton save = new JButton("save");
            ActionListener al = new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JButton button = (JButton)e.getSource();
                    if(button == open)
                        showOpenDialog();
                    if(button == save)
                        showSaveDialog();
            open.addActionListener(al);
            save.addActionListener(al);
            JPanel panel = new JPanel();
            panel.add(open);
            panel.add(save);
            return panel;
        public static void main(String[] args) {
            ChopShop chopShop = new ChopShop();
            ClipMover mover = new ClipMover(chopShop);
            chopShop.addMouseListener(mover);
            chopShop.addMouseMotionListener(mover);
            JFrame f = new JFrame("click inside rectangle to drag");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(chopShop));
            f.getContentPane().add(chopShop.getControls(), "Last");
            f.pack();
            f.setLocation(200,100);
            f.setVisible(true);
    class ImageFilter extends FileFilter {
        static String GIF = "gif";
        static String JPG = "jpg";
        static String PNG = "png";
        // bmp okay in j2se 1.5+
        public boolean accept(File file) {
            if(file.isDirectory())
                return true;
            String ext = getExtension(file).toLowerCase();
            if(ext.equals(GIF) || ext.equals(JPG) || ext.equals(PNG))
                return true;
            return false;
        public String getDescription() {
            return "gif, jpg, png images";
        public String getExtension(File file) {
            String s = file.getPath();
            int dot = s.lastIndexOf(".");
            return (dot != -1) ? s.substring(dot+1) : "";
    class ClipMover extends MouseInputAdapter {
        ChopShop component;
        Point offset = new Point();
        boolean dragging = false;
        public ClipMover(ChopShop cs) {
            component = cs;
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            if(component.clip.contains(p)) {
                offset.x = p.x - component.clip.x;
                offset.y = p.y - component.clip.y;
                dragging = true;
        public void mouseReleased(MouseEvent e) {
            dragging = false;
        public void mouseDragged(MouseEvent e) {
            if(dragging) {
                int x = e.getX() - offset.x;
                int y = e.getY() - offset.y;
                component.setClip(x, y);
    }

  • Sizing jpg or gif images to use in DW

    Being new I am unaccustomed to the sizing (pixels) as much as I probably should be. I have Adobe Photoshop, Illustrator, InDesign, Dreamweaver, etc. I understand that you should use images of titles, etc. that you want to use different fonts for since your recipients fonts will affect the way your webpage appears. My problem is this. It appeared that I had about 600 pixels wide and 70 pixels  high for the space that I wanted to put the title of a newsletter in. When I tried to create the title in Photoshop it comes in way too small or way to big. Not sure what I should be doing. Also, I then read that everything you put in your website should be really small. Is there a standard size of things that I should be trying to create? Is there information somewhere that I can research to help me understand the pixel sizes more and how to achieve them?

    In Photoshop, Save For Web.  Use the smallest FILE SIZE necessary for the job (25-50 KB).
    http://www.larry-bolch.com/save-for-web/photoshop.htm
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com

  • Storing jpg or gif images in database

    Hi,
    I want to store the images from system folder to database.
    Ex: "c:/images"
    is the foldername
    I want to access this folder from JSP and want to store a selected image from the user to database and getting back that image to view by a query. so how can i achive this.....

    Hi All,
    I have 2 things to discuss in this thread.
    First to store Images in Database: We can store Images as Binary content in the Database with the Datatype as BLOB. This is possible in ORACLE. I am not sure what the Datatype is in other RDBMS. Please refer to Vendor documentation. After storing, the content can be retrieved and displayed in the pages as image resources using a Servlet. The Servlet will only render the content of the Image.
    Second to load Images from User's Systems folder: Why do you have such a requirement? Even then, you need to use any common techniques like Multipart form to upload the specific image file to the Server. Kindly read Oreilley's Multipart Request Form Object example for implementation.
    Thanks and regards,
    Pazhanikanthan. P

  • How can I have images open in their original applications from Links panel?

    Before I switched to my new Mac, I was able to open files in their original applications when I clicked the Edit Original button at the bottom of the Links panel. But now everything—TIFF, EPS and PDF—opens in Preview because that's the default application set to open any link files and it's really frustrating. How can I change it so I can open Photoshop files in Photoshop, EPS files in Illustrator and PDF files in Acrobat. I know I can always go to the drop down menu to choose Edit With...and choose an application but I'm so used to clicking the Edit Original button.

    in finder/ not ID... right click on a file eg tiff: get info: open with: select PS,
    G

  • How to make mounted images open

    Before not to long ago, when i would mount or download a dmg image, it would automatically open. It no longer does that. Is there anyway that I can restore that feature, I found it really useful.
    Tyler

    Hasn;t been in the OS for longer then that, maybe you had a hot folder script doing ti for you. As I said it's not a good idea anyway, bug security hole. (opening any downloaded file automatically is a security hole).
    regards

  • How to deal with addition of .jpg or .gif file

    how do i add a LARGE .jpg or .gif image to a JPanel? and is it possible to add JTextField or other features onto the .jpg or .gif file after the addition of the image?
    Thanks for the time and consideration.

    If you want the image to just be the background for a panel then you will need to subclass JPanel and override the paintComponent(Graphics) method. In the paintComponent(Graphics) method you will need to draw the image yourself using the Graphics.drawImage() method. For loading the image I would suggest using one of the ImageIO.read() methods.

  • Links in JPG & GIF images.

    Hello board,
    I'm making some JPGs & animated GIFs for my website, and my CMS allows images to link to only a single link; e.g. it
    links the whole image.  Is it possible to embed multiple links in a single image THEN upload to one's CMS?  If so, how?

    Marian Driscoll wrote:
    JPG and GIF image files cannot contain even a single link. Links are only made through HTML.
    You can slice the image (see Photoshop help on 'slicing') and then apply unique links to each slice in the CMS' WYSIWYG editor.
    You can also manually enter a HTML image map for a single image file if your CMS allows raw HTML and does not filter that type of input.
    Or you can use Dreamweaver.

Maybe you are looking for

  • How to edit a standard  form and print progarm

    hi experts,               I have lot of standard scripts for my works.but it is very tough to change the print progarm according to our own forms.Is there any easy way yo change the print progarm???? and some of the print progarms are not avilable fo

  • Hardware test and disk repair

    Hi: I'm relatively new to the mac world and I have a Mini, core solo, intel. I have two questions that I hope you can answer: 1. How do I do a hardware test? 2. How do I repair the disk via the CD that came with the Mini? When I install the disk, it

  • DNS error when launching Application login page after R12 installation

    Hi , I installed R12.0.4 on windows server 2003. After installation when I launch the home page, its giving dns error saying that <domainname>.<hostname> cannot be loaded. I checked the apache alert log, it is trying to access an IP that is commented

  • Wi-fi doesn't work in lion osx

    My wi.fi connection crashes every 2 minutes in my macbook pro after installing osx lion. How can i solve the problem?

  • Heads up - LG 8523B Cdrom

    Hey Hey, got the K8N-LSR in yesterday, and have had a whole load of problems.  Normally this would be fine, as I expect a few hiccups when moving to a new platform, however we've been pushing my boss to at least start selling AMD systems - and this i