Image (jpeg, gif) display in AWT layout manager

Goodmorning All,
I am looking for some help, a hint on my AWT Layout challenge i have.
Example GUI_1:
=========================
Window border..................[_][x]..
=========================
[label]....|display_area|....[button].
[label]....|display_area|....[button].
...............|display_area|....[button].
...............|display_area|....[button].
...............|display_area|..................
=========================
...........................................[QUIT].....
=========================
I want to
- display a picture in the "display area" of the this GUI
- put labels left of it with some text
- put a couple of buttons right of it, through which i am able to manipulate the image
Questions:
*1. Is it (even) possible to display an (jpeg,gif) image in the "display area" while using a layout manager?*
Surfing over the internet...so far i only have found applet-examples that use the full gui surface of the applet to display an image via the g.drawImage (imagename, x,y); without any gui elements (labels, buttons) beside it.
*2. What kind of AWT gui element do i need at the location of the "display area"?*
Is is possible to use a CANVAS or do i need somethen else? (e.g. glue an image on a button)
*3. Is is possible to display an ANIMATION (series of sequences jpeg, gifs) in the display area?*
I already found out how to locate and load the images (via mediatracker).
Now i need to find a way to "paint" the loaded images in the GUI.
*4. Is this even possible with AWT layout or do i need to switch to SWING layout?*
I have not used Swing yet, cause i'm working my way up through the oldest gui technologie first.
*5. Do know any usefull websites, online tutorials (on awt and displaying images) that can help me tackle my challenge?*
Thank you very much for your hints, tips and tricks

A link as Gary pointed out is the best way to see what the problem may be.
Did you save the image to your working folder and have you defined a site pointing to this folder.
Defining a site helps Dreamweaver track and organize the files used in this site.
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14028
If you can't see the image, this means that the path to the image is incorrect.
Nadia
Adobe Community Expert : Dreamweaver
Unique CSS Templates | Tutorials | SEO Articles
http://www.DreamweaverResources.com
Web Design & Development
http://www.perrelink.com.au
http://twitter.com/nadiap

Similar Messages

  • Serverside conversion of PDF to Image (JPEG, GIF, PNG)

    Hello JDCers.....
    I am currently looking for a serverside component (or some info on how to build one).... that will allow on the fly conversion of pdf to an image format on my web server...
    Any help would be greatly appreciated....
    Thanks
    Fahim

    here is some code that does the trick...
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.image.BufferedImage;
    import java.awt.image.RenderedImage;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.util.Vector;
    import javax.imageio.ImageIO;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletResponse;
    import com.sun.media.jai.codec.ImageCodec;
    import com.sun.media.jai.codec.ImageDecoder;
    import com.sun.media.jai.codec.ImageEncoder;
    import com.sun.media.jai.codec.PNGEncodeParam;
    import com.sun.media.jai.codec.SeekableStream;
    import com.sun.media.jai.codec.TIFFDecodeParam;
    import com.sun.media.jai.codec.TIFFDirectory;
    import multivalent.Behavior;
    import multivalent.Context;
    import multivalent.Document;
    import multivalent.Node;
    import multivalent.std.adaptor.pdf.PDF;
    public class PDFToPNG extends HttpServlet {
         private static final long serialVersionUID = 1L;
         public byte[] ConvertToPngImage(byte[] tiffRawData, HttpServletResponse res)
                   throws Exception {
              Vector pngs = new Vector();
              // set stream to the tiff url
              SeekableStream tiffStream = SeekableStream.wrapInputStream(
                        new ByteArrayInputStream(tiffRawData), true);
              // how many pages in one tiff
              int pageNumber = TIFFDirectory.getNumDirectories(tiffStream);
              TIFFDecodeParam decodeParam = new TIFFDecodeParam();
              decodeParam.setDecodePaletteAsShorts(true);
              ImageDecoder tiffDecoder = ImageCodec.createImageDecoder("tiff",
                        tiffStream, decodeParam);
              // for (int p = 0; p < pageNumber; p ++) {
              // render the current page
              RenderedImage tiffPage = tiffDecoder.decodeAsRenderedImage();
              PNGEncodeParam png = PNGEncodeParam.getDefaultEncodeParam(tiffPage);
              // The png stream is outputted to a file. Change the directory
              // accordingly.
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              // Gets a PNG encoder.
              ImageEncoder pngEncoder = ImageCodec.createImageEncoder("PNG", baos,png);
              // Encodes the RenderedImage object.
              pngEncoder.encode(tiffPage);
              byte[] content = baos.toByteArray();
              baos.close();
              return content;
         public static void main(String args[]) {
              File outfile = new File("c:\\file.png");
              try {
                   PDF pdf = (PDF) Behavior.getInstance("AdobePDF", "AdobePDF", null,
                             null, null);
                   File file = new File("c:\\somepdf.pdf");
                   pdf.setInput(file);
                   Document doc = new Document("doc", null, null);
                   pdf.parse(doc);
                   doc.clear();
                   doc.putAttr(Document.ATTR_PAGE, Integer.toString(1));
                   pdf.parse(doc);
                   Node top = doc.childAt(0);
                   doc.formatBeforeAfter(200, 200, null);
                   int w = top.bbox.width;
                   int h = top.bbox.height;
                   BufferedImage img = new BufferedImage(w, h,
                             BufferedImage.TYPE_INT_RGB);
                   Graphics2D g = img.createGraphics();
                   g.setClip(0, 0, w, h);
                   g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                             RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
                   g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
                   g.setRenderingHint(RenderingHints.KEY_RENDERING,
                             RenderingHints.VALUE_RENDER_QUALITY);
                   Context cx = doc.getStyleSheet().getContext(g, null);
                   top.paintBeforeAfter(g.getClipBounds(), cx);
                   ImageIO.write(img, "png", outfile);
                   doc.removeAllChildren();
                   cx.reset();
                   g.dispose();
                   pdf.getReader().close();
                   outfile = null;
                   doc = null;
              } catch (Exception e) {
    }

  • Save Applet as a jpeg/gif image

    I wrote a small applet to draw some lines.
    it work fine.
    What i want to know is how can i save this applet to a jpeg/gif file.
    (Assume there is a Button in the Applet or Even in the HTML page; when click the button needs to save the applet as an image file)
    is it possible??
    import java.applet.*;
    import java.awt.*;
    public class Test extends Applet {
       int width, height;
       public void init() {
          width = getSize().width;
          height = getSize().height;
          setBackground( Color.black );
       public void paint( Graphics g ) {
          g.setColor( Color.green );
          for ( int i = 0; i < 10; ++i ) {
             g.drawLine( width, height, i * width / 10, 0 );
    <applet code="Test" width="300" height="300">
    </applet>
    Message was edited by:
    jugp

    After finding out some facts i tried to do like this;
    but still having some runtime exceptions....
    need help from anybody!!!
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import javax.imageio.ImageIO;
    import java.io.File;
    import java.io.IOException;
    public class Test extends Applet implements ActionListener{
       int width, height;
    Image backbuffer;
       Button save;
       public void init() {
          save = new Button("save");
          add(save);
          save.addActionListener(this);
               width = getSize().width;
          height = getSize().height;
          setBackground( Color.black );
       public void paint( Graphics g ) {
          g.setColor( Color.green );
          for ( int i = 0; i < 10; ++i ) {
             g.drawLine( width, height, i * width / 10, 0 );
       public void actionPerformed(ActionEvent e) {
         String cmd = e.getActionCommand();  
         if (cmd.equals("save")){
                 BufferedImage bufferedImage = new BufferedImage ( width, height,
                       BufferedImage.TYPE_INT_BGR  );
                        bufferedImage.createGraphics().drawImage( backbuffer, 0, 0, this);
                   try {
                        ImageIO.write( bufferedImage, "jpg", new File ( "image.jpg" ) );
                   } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
    <applet code="Test" width="300" height="300">
    </applet>
    */

  • Need help to create report with jpeg/gif image

    Hello,
    I need help with creating a form with a special jpeg/gif seal. I never done this Java. Until now, I created all forms with ansi C++ with HP escape characters to draw lines, boxs, and text. This form will contain boxes which is populated with database information read from a text file.
    Since this form contains a special seal on the upper right, I don't think it can be done with old fashion ansi C++. How can I create a form with Java and create it as a simple exe to just print the form to a specified printer.
    Thanks,
    John

    Hi,
    I am creating a form with boxes (lines and text). What is special about this form is that it has an image jpeg or gif at the top right corner. Is is a state department seal. Up to this form, I had used ansi C++ and print out escape HP character to print out the lines, boxes, and text. I have no idea how to print out the image. I am new to JAVA and only 1 class in it. Is there sample code out there to create this type of form with the image? I need a starting point.
    Thanks,
    John

  • How can i convert an image into gif file as jpeg by using com.sun.image.*

    please help me to convert an image into gif format. i have used sun's impl com.sun.image.code.jpeg package to convert a buffered image into a jpeg file. is there any implementatioln available from sun to handle gif files.

    Many. Try for instance google with 'java image encoders'. Go to the URL http://www.google.com/search?q=java+image+encoders and be amazed of the wonders of modern web search tools.

  • How to display thumbnail image of file in KM navigation layout

    Hi, I'm using a km nav iview to display some files to my users.  The files are all images and it would be more useful if the images could be displayed right upfront instead of clicking on the file name and having the page reload with preview. 
    I am aware of the layout "TreeList preview explorer", does anyone know of another way to add a thumbnail next to the file name just in a new column instead of in the preview area?
    Thanks and regards,
    Scott

    Scott,
    Check this http://help.sap.com/saphelp_nw04/helpdata/en/03/bd7440036f6d1de10000000a1550b0/frameset.htm :
    Thumbnails
    You use the Thumbnails layout profile to display folders that contain images or documents for which thumbnails are supported.
    Regards,
    Andrei

  • Can assets be images of type jpeg,gif,Tiff,etc... ?

    Hi,
    I am working  on ES2.
    I am able to take PDF file as form to the  my  process. Here  my  new requirement is   in addition to  pdf  I need to take all types  of  images
    say jpeg,gif, and Tiff  as  input to my  process.  But I am not able to do that bcas Workbench only  takes *.pdf as input.
    If you have other extensions  expect  pdf,  while   taking the asset into the  start activity, I  could  not  find that  file in the  application.
    Please help me in this regard how  workbench takes  all image files as inputs into  the  process.
    Thanks
    Praveen.

    Hi Scott,
    Thanks for your reply.
    Yes   I  have to use as image file as form  to the process.
    I am using  Adobe LC ES2.
    Let  me explian my  requirement :  I have  scanned image   and  need to use that image as input to the process i mean image as form  to the process.
    I will invoke the process then  scanned image should come as form  in the  workspace .
    Please help in this regard.
    Thanks
    Praveen.

  • How can i write the image in gif or jpeg format??

    how can i write the image in gif or jpeg format??

    thx someone else help me in another topic

  • JPEG/GIF image to BASE64

    Hi,
    I like to convert JPEG/GIF or any type of image into BASE64 format and Viceversa. Can somebody provide me the java code for doing this.
    Cheers,
    Siva Maranani.

    Rather than use an undocumented API, I would suggest a 3rd party library for Base64 encoding such as the one that I wrote:
    http://ostermiller.org/utils/Base64.html
    It even has several convenience methods for encoding files:
    static void      encode(File fIn)
    Encode this file in Base64.
    static void      encode(File fIn, boolean lineBreaks)
    Encode this file in Base64.
    static void      encode(File fIn, File fOut)
    Encode this file in Base64.
    static void      encode(File fIn, File fOut, boolean lineBreaks)
    Encode this file in Base64.

  • Layout manager issue.

    I was hoping that someone could shed some light on why one layout manage will allow an applet to be inserted in a class that extends JFrame but not another.
    Here is the guts of the problem I have an class that extends applet to display a pie chart. I then have a seperate class that extends JFrame that display two input boxes and a button. When the user enters two fields and clicks draw the pie chart displays working with the two numbers. The JFrame class that works uses the border layout. I change the class to use gridbag, and now only the textboxes display. Can anyone help. Here is the code for the three classes.
    This is the applet class....
    * File: PieChart.java
    * PieChart class is an Swing applet that use a pie chart
    * to show the percentage. It is used by PieChartExample
    * to show what percetange of a payment actually goes to
    * pay interest. There is no error handling in the program.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PieChart extends JApplet {
    final static Color bg = Color.white;
    final static Color fg = Color.black;
    private double percent;
    public void init() {
    //Initialize drawing colors
    setBackground(bg);
    setForeground(fg);
    percent = 1.0;
         public void setPercentage(double pct) {
              this.percent = pct;
    public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setPaint(fg);
    drawAnnotation(g2);
    drawArc(g2, percent);
    public void drawAnnotation(Graphics2D g2) {
              // draw a small green circle
              g2.setPaint(Color.green);
    g2.fill(new Ellipse2D.Double(200, 200, 10,10));
    // draw a small red circle
    g2.setPaint(Color.red);
    g2.fill(new Ellipse2D.Double(270, 200, 10, 10));
    g2.setPaint(Color.black);
    g2.drawString("Interest", 210, 210); // write "Interest" by green circle
    g2.drawString("Principal", 280, 210); // write "Principal" by red circle
         public void drawArc(Graphics2D g2, double percent) {
    // draw the interest portion
              g2.setPaint(Color.green);
              g2.fill(new Arc2D.Double(10,10,200,200, 0, percent * 360, Arc2D.PIE));
              // draw the rest (principal portion)
              g2.setPaint(Color.red);
              g2.fill(new Arc2D.Double(10,10,200,200, percent * 360, (1-percent)*360, Arc2D.PIE));
    This is the JFrame class using Boarderlayout that works.
    * File: PieChartExample.java
    * The program demonstrate a simple use of pie chart. It takes total
    * payment and interest paid from user input and draws a pie chart
    * to show the percentage of interert to total payment. There is no
    * error handling whatsoever in the example program, so you can see
    * that it can be broken easily.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PieChartExample extends JFrame {
         final static int CHART_WIDTH = 800;
         final static int CHART_HEIGHT = 300;
         JPanel panel ;
         JLabel paymentLabel;
         JTextField paymentField;
         JLabel interestLabel;
         JTextField interestField;
         JButton show;
    PieChart applet;
    public PieChartExample() {
    super("Pie Chart Example");
    panel = new JPanel();
    paymentLabel = new JLabel("Payment: $");
    panel.add(paymentLabel);
    paymentField = new JTextField(10);
    panel.add(paymentField);
    interestLabel = new JLabel("Interest: $");
    panel.add(interestLabel);
    interestField = new JTextField(10);
    panel.add(interestField);
    show = new JButton("Draw");
    panel.add(show);
    this.getContentPane().add("North", panel);
    applet = new PieChart();
    this.getContentPane().add("Center", applet);
    show.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                        double interest = Double.parseDouble(interestField.getText());
                        double payment = Double.parseDouble(paymentField.getText());
                        double percent = interest / payment;
                        //System.out.println("In event handler, percent is " + percent);
                        applet.setPercentage(percent);
                        applet.repaint();
    private static void createAndShowGUI() {
    PieChartExample f = new PieChartExample();
    f.pack();
    f.setSize(new Dimension(CHART_WIDTH ,CHART_HEIGHT));
    f.show();
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    This is the modified class to use GridBag that fails.
    * File: PieChartExample2.java
    * The program demonstrate a simple use of pie chart. It takes total
    * payment and interest paid from user input and draws a pie chart
    * to show the percentage of interert to total payment. There is no
    * error handling whatsoever in the example program, so you can see
    * that it can be broken easily.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PieChartExample2 extends JFrame {
         final static int CHART_WIDTH = 800;
         final static int CHART_HEIGHT = 300;
         JPanel panel ;
         JLabel paymentLabel;
         JTextField paymentField;
         JLabel interestLabel;
         JTextField interestField;
         JButton show;
    PieChart applet;
    public PieChartExample2() {
    super("Pie Chart Example");
    // Get container and set layout manager
    Container contentPane = getContentPane();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    contentPane.setLayout(gridbag);
    c.fill = GridBagConstraints.HORIZONTAL;
    panel = new JPanel();
    paymentLabel = new JLabel("Payment: $");
    panel.add(paymentLabel);
    paymentField = new JTextField(10);
    panel.add(paymentField);
    interestLabel = new JLabel("Interest: $");
    panel.add(interestLabel);
    interestField = new JTextField(10);
    panel.add(interestField);
    show = new JButton("Draw");
    panel.add(show);
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(panel, c);
    contentPane.add(panel);
    applet = new PieChart();
    c.gridx = 0;
    c.gridy = 1;
    gridbag.setConstraints(applet, c);
    contentPane.add(applet);
    show.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                        double interest = Double.parseDouble(interestField.getText());
                        double payment = Double.parseDouble(paymentField.getText());
                        double percent = interest / payment;
                        //System.out.println("In event handler, percent is " + percent);
                        applet.setPercentage(percent);
                        applet.repaint();
    private static void createAndShowGUI() {
    PieChartExample2 f = new PieChartExample2();
    f.pack();
    f.setSize(new Dimension(CHART_WIDTH ,CHART_HEIGHT));
    f.show();
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    }

    Ok. It seems I may be wrong and that this may not be a concurrent call issue. I overode the components setBounds and setLocation methods and it appears that an external class is updating the position of these components while layoutContainer is attempting to position them. I can see that the correct positions are being set in the setBounds method, but this is happening after layoutContainer has called getLocation on the components. To be a little more specific, I am using a JLayeredPane to display some overlapping JLabels with images. I have implemented drag and drop on these labels so that dropping one on another swaps the images. The label positions and sizes are not being changed during the drop (I don't want them to move or resize just change images). However, for some reason I have yet to discover, two calls to set bounds are being made on the labels. The first call is relocating the label to the second labels position, the second call is relocating the label back to it's original position. If anyone has any insight on why the label position are changing when I am not explicitly repositioning them please reply. I will post another reply when I have corrected the problem or found a work around for it. I am awarding the dukes to tjacobs1 since he was the only responses I've had so far.

  • Capture images (JPEG) from IP-Camera

    Hey there!
    I have been trying to capture images from an IP-Camera. I understand that this has to be done by using a custom DataSource and I have tried many many example found here on the net, but with no results.
    I think I've tried every piece of code found here at this forum regarding this subject.. :/
    The best I could do was not getting an error while creating a custom DataSource from a BufferedStream..but the when I try to configure/realize the Processor - created with Manager.createProcessor(customdatasource) - it gives me an error which, I think, has something to do with unrecognized content..
    I could post all the examples I tried but I think it would be too much of a confusion so...does anyone have a full working example of code to achieve this? WITH the frame grabber class? plizzzzzzzzz?
    Thanks,
    Edd

    I felt Captfoss' solution was inspired and so gave it a go. The following builds a video from an ip cam jpg stream using a version of Sun's JpegImagesToMovie.java. It is hacked together quickly and with scope for improvement, but it works, proves the idea, and is a good example.
    Run as:- java JpegImagesToMovie -w 320 -h 240 -f 30 -o file:test.avi
    * @(#)JpegImagesToMovie.java     1.3 01/03/13
    * Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
    * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
    * modify and redistribute this software in source and binary code form,
    * provided that i) this copyright notice and license appear on all copies of
    * the software; and ii) Licensee does not utilize the software in a manner
    * which is disparaging to Sun.
    * This software is provided "AS IS," without a warranty of any kind. ALL
    * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
    * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
    * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
    * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
    * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
    * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
    * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
    * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
    * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
    * POSSIBILITY OF SUCH DAMAGES.
    * This software is not designed or intended for use in on-line control of
    * aircraft, air traffic, aircraft navigation or aircraft communications; or in
    * the design, construction, operation or maintenance of any nuclear
    * facility. Licensee represents and warrants that it will not use or
    * redistribute the Software for such purposes.
    * Some public domain modifications by Andy Dyble for avi etc by self and from 
    * other internet resources 19/11/2008. Reads editable 20 ip cam network jpg files.
    * Supported formats tested for compression options. This code could be much improved
    * further to these amendments. Absolutely no warranties. www.exactfutures.com
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.awt.Dimension;
    import javax.media.*;
    import javax.media.control.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.datasink.*;
    import javax.media.format.VideoFormat;
    import javax.media.format.JPEGFormat;
    * This program takes a list of JPEG image files and convert them into
    * a QuickTime movie.
    public class JpegImagesToMovie implements ControllerListener, DataSinkListener {
        public boolean doIt(int width, int height, int frameRate, Vector inFiles, MediaLocator outML, String outputURL)
         ImageDataSource ids = new ImageDataSource(width, height, frameRate, inFiles);
         Processor p;
         try {
             System.err.println("- create processor for the image datasource ...");
             p = Manager.createProcessor(ids);
         } catch (Exception e) {
             System.err.println("Yikes!  Cannot create a processor from the data source.");
             return false;
         p.addControllerListener(this);
         // Put the Processor into configured state so we can set
         // some processing options on the processor.
         p.configure();
         if (!waitForState(p, p.Configured)) {
             System.err.println("Failed to configure the processor.");
             return false;
         // Set the output content descriptor to QuickTime.
         if(outputURL.endsWith(".avi") || outputURL.endsWith(".AVI"))
              p.setContentDescriptor(new ContentDescriptor(FileTypeDescriptor.MSVIDEO));
         if(outputURL.endsWith(".mov") || outputURL.endsWith(".MOV"))
              p.setContentDescriptor(new ContentDescriptor(FileTypeDescriptor.QUICKTIME));
         // Query for the processor for supported formats.
         // Then set it on the processor.
         TrackControl tcs[] = p.getTrackControls();
         for(int i=0;i<tcs.length;i++)
              System.out.println("TrackControl "+i+" "+tcs);
         Format f[] = tcs[0].getSupportedFormats();
         if (f == null || f.length <= 0) {
         System.err.println("The mux does not support the input format: " + tcs[0].getFormat());
         return false;
         for(int i=0;i<f.length;i++)
              System.out.println("Supported Format "+i+" "+f[i]);
    //     tcs[0].setFormat(f[0]);
         if(outputURL.endsWith(".avi") || outputURL.endsWith(".AVI"))     // must be VideoFormat
              System.err.println("Setting the track format to: "     // INDEO50 CINEPAK f[0] etc
                   + tcs[0].setFormat(new VideoFormat(VideoFormat.INDEO50)));
         if(outputURL.endsWith(".mov") || outputURL.endsWith(".MOV"))
              System.err.println("Setting the track format to: "     // JPEG CINEPAK RGB f[0] etc
                   + tcs[0].setFormat(new VideoFormat(VideoFormat.JPEG)));
         //System.err.println("Setting the track format to: " + f[0]);
         // We are done with programming the processor. Let's just
         // realize it.
         p.realize();
         if (!waitForState(p, p.Realized)) {
         System.err.println("Failed to realize the processor.");
         return false;
         // Now, we'll need to create a DataSink.
         DataSink dsink;
         if ((dsink = createDataSink(p, outML)) == null) {
         System.err.println("Failed to create a DataSink for the given output MediaLocator: " + outML);
         return false;
         dsink.addDataSinkListener(this);
         fileDone = false;
         System.err.println("start processing...");
         // OK, we can now start the actual transcoding.
         try {
         p.start();
         dsink.start();
         } catch (IOException e) {
         System.err.println("IO error during processing");
         return false;
         // Wait for EndOfStream event.
         waitForFileDone();
         // Cleanup.
         try {
         dsink.close();
         } catch (Exception e) {}
         p.removeControllerListener(this);
         System.err.println("...done processing.");
         return true;
    * Create the DataSink.
    DataSink createDataSink(Processor p, MediaLocator outML) {
         DataSource ds;
         if ((ds = p.getDataOutput()) == null) {
         System.err.println("Something is really wrong: the processor does not have an output DataSource");
         return null;
         DataSink dsink;
         try {
         System.err.println("- create DataSink for: " + outML);
         dsink = Manager.createDataSink(ds, outML);
         dsink.open();
         } catch (Exception e) {
         System.err.println("Cannot create the DataSink: " + e);
         return null;
         return dsink;
    Object waitSync = new Object();
    boolean stateTransitionOK = true;
    * Block until the processor has transitioned to the given state.
    * Return false if the transition failed.
    boolean waitForState(Processor p, int state) {
         synchronized (waitSync) {
         try {
              while (p.getState() < state && stateTransitionOK)
              waitSync.wait();
         } catch (Exception e) {}
         return stateTransitionOK;
    * Controller Listener.
    public void controllerUpdate(ControllerEvent evt) {
         if (evt instanceof ConfigureCompleteEvent ||
         evt instanceof RealizeCompleteEvent ||
         evt instanceof PrefetchCompleteEvent) {
         synchronized (waitSync) {
              stateTransitionOK = true;
              waitSync.notifyAll();
         } else if (evt instanceof ResourceUnavailableEvent) {
         synchronized (waitSync) {
              stateTransitionOK = false;
              waitSync.notifyAll();
         } else if (evt instanceof EndOfMediaEvent) {
         evt.getSourceController().stop();
         evt.getSourceController().close();
    Object waitFileSync = new Object();
    boolean fileDone = false;
    boolean fileSuccess = true;
    * Block until file writing is done.
    boolean waitForFileDone() {
         synchronized (waitFileSync) {
         try {
              while (!fileDone)
              waitFileSync.wait();
         } catch (Exception e) {}
         return fileSuccess;
    * Event handler for the file writer.
    public void dataSinkUpdate(DataSinkEvent evt) {
         if (evt instanceof EndOfStreamEvent) {
         synchronized (waitFileSync) {
              fileDone = true;
              waitFileSync.notifyAll();
         } else if (evt instanceof DataSinkErrorEvent) {
         synchronized (waitFileSync) {
              fileDone = true;
              fileSuccess = false;
              waitFileSync.notifyAll();
         public static void createInputFiles(Vector files)
              // Create a file for the directory
              File file = new File("images");
              // Get the file list...
              String s[] = file.list();
              files.removeAllElements();     // if any set from arguments
              for(int i=0;i<s.length;i++)
                   if(s[i].indexOf(".jp")!=-1)
                        files.addElement("images"+File.separator+s[i]);     // and to sort if required
                   else
                        System.out.println((i+1)+": "+s[i]+" - ignored");
    public static void main(String args[]) {
         if (args.length == 0)
         prUsage();
         // Parse the arguments.
         int i = 0;
         int width = -1, height = -1, frameRate = 1;
         Vector inputFiles = new Vector();
         String outputURL = null;
         while (i < args.length) {
         if (args[i].equals("-w")) {
              i++;
              if (i >= args.length)
              prUsage();
              width = new Integer(args[i]).intValue();
         } else if (args[i].equals("-h")) {
              i++;
              if (i >= args.length)
              prUsage();
              height = new Integer(args[i]).intValue();
         } else if (args[i].equals("-f")) {
              i++;
              if (i >= args.length)
              prUsage();
              frameRate = new Integer(args[i]).intValue();
         } else if (args[i].equals("-o")) {
              i++;
              if (i >= args.length)
              prUsage();
              outputURL = args[i];
         } else {
              inputFiles.addElement(args[i]);
         i++;
    ///     createInputFiles(inputFiles);
         if (outputURL == null)// || inputFiles.size() == 0)
         prUsage();
         // Check for output file extension.
         if(!outputURL.endsWith(".avi") && !outputURL.endsWith(".AVI") && !outputURL.endsWith(".mov") && !outputURL.endsWith(".MOV"))
              System.err.println("The output file extension should end with a .mov extension");
              prUsage();
         if (width < 0 || height < 0) {
         System.err.println("Please specify the correct image size.");
         prUsage();
         // Check the frame rate.
         if (frameRate < 1)
         frameRate = 1;
         // Generate the output media locators.
         MediaLocator oml;
         if ((oml = createMediaLocator(outputURL)) == null) {
         System.err.println("Cannot build media locator from: " + outputURL);
         System.exit(0);
         JpegImagesToMovie imageToMovie = new JpegImagesToMovie();
         imageToMovie.doIt(width, height, frameRate, inputFiles, oml, outputURL);
         System.exit(0);
    static void prUsage() {
         System.err.println("Usage: java JpegImagesToMovie -w <width> -h <height> -f <frame rate> -o <output URL>");// <input JPEG file 1> <input JPEG file 2> ...");
         System.exit(-1);
    * Create a media locator from the given string.
    static MediaLocator createMediaLocator(String url) {
         MediaLocator ml;
         if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null)
         return ml;
         if (url.startsWith(File.separator)) {
         if ((ml = new MediaLocator("file:" + url)) != null)
              return ml;
         } else {
         String file = "file:" + System.getProperty("user.dir") + File.separator + url;
         if ((ml = new MediaLocator(file)) != null)
              return ml;
         return null;
    // Inner classes.
    * A DataSource to read from a list of JPEG image files and
    * turn that into a stream of JMF buffers.
    * The DataSource is not seekable or positionable.
    class ImageDataSource extends PullBufferDataSource {
         ImageSourceStream streams[];
         ImageDataSource(int width, int height, int frameRate, Vector images) {
         streams = new ImageSourceStream[1];
         streams[0] = new ImageSourceStream(width, height, frameRate, images);
         public void setLocator(MediaLocator source) {
         public MediaLocator getLocator() {
         return null;
         * Content type is of RAW since we are sending buffers of video
         * frames without a container format.
         public String getContentType() {
         return ContentDescriptor.RAW;
         public void connect() {
         public void disconnect() {
         public void start() {
         public void stop() {
         * Return the ImageSourceStreams.
         public PullBufferStream[] getStreams() {
         return streams;
         * We could have derived the duration from the number of
         * frames and frame rate. But for the purpose of this program,
         * it's not necessary.
         public Time getDuration() {
         return DURATION_UNKNOWN;
         public Object[] getControls() {
         return new Object[0];
         public Object getControl(String type) {
         return null;
    * The source stream to go along with ImageDataSource.
    class ImageSourceStream implements PullBufferStream {
         Vector images;
         int width, height;
         VideoFormat format;
         int nextImage = 0;     // index of the next image to be read.
         boolean ended = false;
         float frameRate;
         long seqNo = 0;
         public ImageSourceStream(int width, int height, int frameRate, Vector images) {
         this.width = width;
         this.height = height;
         this.images = images;
              this.frameRate = (float)frameRate;
         format = new VideoFormat(VideoFormat.JPEG,
                        new Dimension(width, height),
                        Format.NOT_SPECIFIED,
                        Format.byteArray,
                        (float)frameRate);
         * We should never need to block assuming data are read from files.
         public boolean willReadBlock() {
         return false;
    byte[] input_buffer;
    byte[] imgbytearray;
    byte[] imgusebyte;
    int camWidth = 320;
    int camHeight = 240;
    URL url;
    long timeStamp;long timeStamp0=System.currentTimeMillis();long resultTimeStamp;
         public boolean urlFetchJPG()
              String ipcamserver = "146.176.65.10";     // examples 146.176.65.10 , 62.16.100.204 , 194.168.163.96 , 84.93.217.139 , 194.177.131.229 , 148.61.171.201
              try
                   url = new URL("http://"+ipcamserver+"/axis-cgi/jpg/image.cgi?camera=&resolution=320x240".trim());
              catch(Exception e){System.out.println("Exception url "+e);}
              try
                   if(input_buffer==null)input_buffer = new byte[8192];
                   if(imgbytearray==null)imgbytearray = new byte[camWidth*camHeight*3];
                   URLConnection uc = url.openConnection();
                   uc.setUseCaches(false);
                   //uc.setDoInput(true);
                   //uc.setRequestProperty("accept","image/jpeg,text/html,text/plain");
                   BufferedInputStream in;
                   int bytes_read;
                   int sumread=0;
                   in = new BufferedInputStream(uc.getInputStream());
                   while((bytes_read=in.read(input_buffer, 0, 8192))!=-1)
                        if(sumread+bytes_read>imgbytearray.length)
                             byte[] imgbytearraytemp = new byte[sumread+bytes_read+8192];
                             System.arraycopy(imgbytearray,0,imgbytearraytemp,0,imgbytearray.length);
                        System.arraycopy(input_buffer,0,imgbytearray,sumread,bytes_read);
                        sumread=sumread+bytes_read;
                   in.close();
                   imgusebyte = new byte[sumread];
                   System.arraycopy(imgbytearray,0,imgusebyte,0,sumread);
              catch(Exception e){System.out.println("Exception urlFetchJPG "+e);}
              return true;
         * This is called from the Processor to read a frame worth
         * of video data.
         public void read(Buffer buf) throws IOException {
         // Check if we've finished all the frames.
         if (nextImage >= 20) //images.size())
              // We are done. Set EndOfMedia.
              System.err.println("Done reading all images.");
              buf.setEOM(true);
              buf.setOffset(0);
              buf.setLength(0);
              ended = true;
              return;
    ///     String imageFile = (String)images.elementAt(nextImage);
         nextImage++;
    //     System.err.println(" - reading image file: " + imageFile);
         // Open a random access file for the next image.
    ///     RandomAccessFile raFile;
    ///     raFile = new RandomAccessFile(imageFile, "r");
         byte data[] = null;
         // Check the input buffer type & size.
    ///     if (buf.getData() instanceof byte[])
    ///          data = (byte[])buf.getData();
              urlFetchJPG();
              data = imgusebyte;
         // Check to see the given buffer is big enough for the frame.
    ///     if (data == null || data.length < raFile.length()) {
    ///          data = new byte[(int)raFile.length()];
              buf.setData(data);
         // Read the entire JPEG image from the file.
    ///     raFile.readFully(data, 0, (int)raFile.length());
    //     System.err.println(" read " + raFile.length() + " bytes.");
         buf.setOffset(0);
    ///     buf.setLength((int)raFile.length());
              buf.setLength(data.length);
         buf.setFormat(format);
         buf.setFlags(buf.getFlags() | buf.FLAG_KEY_FRAME);
    ///          long time = (long)(seqNo * (1000D / frameRate) * 1000000);
              timeStamp = System.currentTimeMillis();
              resultTimeStamp = timeStamp - timeStamp0;
              long time = resultTimeStamp * 0xf4240L;
              buf.setTimeStamp(time);
              buf.setSequenceNumber(seqNo++);
         // Close the random access file.
    ///     raFile.close();
         * Return the format of each video frame. That will be JPEG.
         public Format getFormat() {
         return format;
         public ContentDescriptor getContentDescriptor() {
         return new ContentDescriptor(ContentDescriptor.RAW);
         public long getContentLength() {
         return 0;
         public boolean endOfStream() {
         return ended;
         public Object[] getControls() {
         return new Object[0];
         public Object getControl(String type) {
         return null;
    {code}

  • Podcast image no longer displaying in iTunes

    My podcast has been in iTunes for around two years, but just within the past week iTunes is not displaying the graphic.  The graphic is still there, and the references in the rss.xml have not changed.  Here's a link to the xml file:
    http://www.thesecularbuddhist.com/rss.xml
    The graphic reference in that files is:
    <itunes:image href="http://www.thesecularbuddhist.com/images/iTunes_Art.gif" />
    Any help would be appreciated, thank you!

    I had the same thing happen to me about two weeks ago, poof my image just dissappeared.
    I went ahead and emailed the support team about the issue and this was their response:
    "Please forward a copy of the image you would like to update your podcast with as well as the iTunes Store URL of your podcast.
    To get the iTunes Store URL, right click or option click on the title in iTunes Store.
    Please ensure that the image is:
    600 x 600 in dimension
    PNG of JPEG format
    Using RGB colorspace"
    I agree with the user above probably a glitch with the Store.

  • Refreshing image ( and not displaying the one in the cache )

    Hello , I made an app with many galleries stored locally but i made another section with a daily image, and this image is located on an ftp server http://XXXXX.com/image.png for example so everyday i upload the new one with the SAME name as the older one
    ( that is replaced by the newest ) , however the app is always displaying the older one , even if i restart the app , the computer or kill completely the app.
    How could i do please?
    Could i add something next to the image url (in a gallery module) to make it refresh everytime the app loads?
    PS : if you couldn't solve this problem could i put a button to refresh the image?
    Thanks
    EDIT : I reinstalled my app and changed several times the image and now it's working?
    Is it temporarily so this image will be cached and the issue will appear once more or was it a bug?

    Hello
    I don't believe you can without addressing/changing the way the image is loaded on your server.
    You have several options to remove the caching even from files you upload.
    You can for example use a .htaccess file in the folder where your image is uploaded
    (assuming your webserver is an apache server)
    <IfModule mod_expires.c>
    # Enable expirations
    ExpiresActive On
    # Default directive
    ExpiresDefault "access plus 1 day"
    # Images
    ExpiresByType image/gif "access plus 1 minute"
    ExpiresByType image/png "access plus 1 minute"
    ExpiresByType image/jpg "access plus 1 minute"
    ExpiresByType image/jpeg "access plus 1 minute"
    </IfModule>
    You can also set the header using a loading script in php, asp or whatever language your server supports (e.g. showimage.php?img=blabla.png which allows you to set the no cache header (or limited cache header) in the php header before loading it in your
    applications (works also for asp, etc.). Any searchengine will give you some inspirational examples.
    Regards
    StonyArc

  • Images won't display in Review mode

    When I send a draft of a page for review, several of the
    images (jpegs and gifs) will not display. Do the images need to be
    formatted in a certain way?

    When the draft is published, are the images visible
    then?

  • How to use image load gif of 「GIF87a」 by ByteArray ?

    Hi all:
    I want use image load gif file of 「GIF87a」 by ByteArray, but it not be displayed correctly on the screen, How can I do it , or How to conver 「GIF87a」 to 「GIF89a」 ?
    private function onButtonClick():void {
        fileRef.browse([new FileFilter("Images", "*.jpg;*.gif;*.png;*.swf")]);
        fileRef.addEventListener(Event.SELECT, onFileSelected);
    private function onFileSelected(e:Event):void {
        fileRef.addEventListener(Event.COMPLETE, onFileLoaded);
        fileRef.load();
    private function onFileLoaded(e:Event):void {
        var bytes:ByteArray = e.target.data;
        imageLoader.source = bytes;
    <mx:Image  id="imageLoader" onclick="onButtonClick()">

    Hi zhaojie198281,
    I've made a small modification on your code and it works fine. Try the following code,
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx"
            width="900" height="400">
    <fx:Script>
      <![CDATA[
       private var fileRef:FileReference = new FileReference();
       private function onButtonClick():void {
        fileRef.browse([new FileFilter("Images", "*.jpg;*.gif;*.png;*.swf")]);
        fileRef.addEventListener(Event.SELECT, onFileSelected);
       private function onFileSelected(e:Event):void {
        fileRef.addEventListener(Event.COMPLETE, onFileLoaded);
        fileRef.load();
       private function onFileLoaded(e:Event):void {
        var bytes:ByteArray = e.target.data;
        imageLoader.source = bytes;
      ]]>
    </fx:Script>
    <fx:Declarations>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:layout>
      <s:VerticalLayout paddingTop="10" paddingLeft="10"/>
    </s:layout>
    <s:Button label="Load!" click="onButtonClick()"/>
    <mx:Image id="imageLoader"/>
    </s:WindowedApplication>

Maybe you are looking for

  • Tuning a sql using tkprof

    The most important query in our application is: SELECT                 COUNT ( * )   FROM            I_JOURNAL m                INNER JOIN                   LIU_TYPES lt                ON (m.LIU_TYPE = lt.LIU_TYPE)             INNER JOIN             

  • MB51, download to excel works different for online and background.

    Hi, Have a question regarding excel download of MB51 in online mode against background. If I run MB51 online, I can download it to an excel sheet that is easy to read and work with. Each column in the report in seperate column in excel. If I run it i

  • Reg:DC to be imported to DTR

    Hi Friends, My DC has been developed on my Local System,sometimes i had updated to DTR and sometimes i did not. Now i need to put this DC on to the DTR from my Local Development . Is it possible for me to do the same. Please let me know,if atall its

  • Re-work mapping in SAP B1

    Hi all How we can map the re-work in SAP B1 like I had released the production order for 100 qty with x-item and made the report completion for 100 qty after that i came to know that 20 has to be reworked which means 20 of the x-item has to issue to

  • How to open .WMV attachments

    How do I open .WMV attachments that arrive in mail messages?