Trying to display an image with eclipse
this is the code:
import javax.microedition.lcdui.*;
import java.io.IOException;
public class DrawImageCanvas extends Canvas{
static Image image;
public void paint(Graphics g){
int width = getWidth();
int height = getHeight();
// Fill the background using black
g.setColor(0);
g.fillRect(0, 0, width, height);
if (image == null) {
try {
image = Image.createImage("E:\\DolfvanElk\\workspace\\HelloWorld\\images.png");
} catch (IOException ex) {
g.setColor(0xffffff);
g.drawString("Failed to load image!", 0, 0, Graphics.TOP | Graphics.LEFT);
return;
but no matter what argument i give to the createImage() function it will always display "Failed to Load Image"
nevermind i'm an idiot. I've figured it out
Sorry for the spam.
Similar Messages
-
Hi Steve/anyone
I am trying to display the image upload and Display using the "Oracle Fusion Developer Guide" page 404 Working with Oracle Multimedia Types by Frank Nimphius and Lynn Munsinger. I tried to replicate the solution in a sample app. My upload works as said. But when i try to browse I dont see the image and i get the following error in the background. Please help. All the steps mentioned have been done
! Edit Images.jspx
<af:inputFile value="#{bindings.Image.inputValue}" simple="true"
id="if1">
<binding:convertOrdDomain bindingRef="#{bindings.Image}"/>
</af:inputFile>
2 Browse Images.jspx
<af:panelLabelAndMessage label="#{bindings.Image.hints.label}"
id="plam1">
<af:media contentType="#{bindings.Image.inputValue.media.mimeType}"
source="#{bindings.Image.inputValue.source}" id="m2"/>
</af:panelLabelAndMessage>
<af:outputText value="#{bindings.Image.inputValue.media.width}" id="ot3"/>
java.lang.NullPointerException
at oracle.ord.html.OrdPlayMediaServlet.renderContent(OrdPlayMediaServlet.java:386)
at oracle.ord.html.OrdPlayMediaServlet.deliver(OrdPlayMediaServlet.java:264)
at oracle.ord.html.OrdPlayMediaServlet.doGet(OrdPlayMediaServlet.java:205)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.model.servlet.ADFBindingFilError showing images using Servlet OrdPlayMediaServlet
-
Can't display an image with SWT using J9
Hello,
I'm programming a user interface using SWT and J9 as JVM under Window Mobile 5.0
Everything seems to work more or less fine with SWT widgets, but I can't display any Image.
I've tried the following codes :
Image image = new Image(display,getClass().getResourceAsStream("image.bmp"));when placing image.bmp in the same jar that my main class, or in the same folder when not using a jar file.
and
Image image = new Image(display,"\\image.bmp");(when placing image.bmp in the root folder)
I've tried with a gif file, it doesn't work neither.
Both codes work fine in my normal computer (replacing "//image.bmp" by "C://image.bmp" for instance)
Any help would be highly appreciated ;-)
Message was edited by:
cOsiHere is a basic example to display image and make it flicker. Use it and try to improve to get the exact frame rate you want.
Remember this is not the actual solution, its just to give you an idea.
The best solution is the one you find it by yourself
Attachments:
Flicker.vi 8 KB -
I tried to display gif image from oracle to jsp but nothing appear
i tried to display image from oracle DB to jsp directly without using file processing , and i used Servlet and jsp , Servlet to get image from DB and jsp to use <img> tag , when i Run Servlet code
the image appaer on Microsoft Photo Editor , and when i run jsp the image dose not appear on jsp page , so please anyone has an idea about this broblem ,send the soluation or any information to my e-mail [email protected] , and I'll thankful about your help.
the Servlet and jsp code are below .
thank for your help
Servlet:
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.PrintWriter;
import java.io.IOException;
public class Servlet extends HttpServlet
public void init(ServletConfig config) throws ServletException
super.init(config);
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
response.setContentType("image/gif");
int id = Integer.parseInt(request.getParameter("no"));
// int id = 2 ; when Run Servlet .
ResultSet rs = null;
Connection Lcon = null;
String stmt = " select Image from ImageTable where lmage_id ="+id;
Statement sm = null;
String data1 ="";
try
Lcon = getConntcion();
sm = Lcon.createStatement();
rs = sm.executeQuery(stmt);
if(rs.next())
InputStream in = rs.getBinaryStream(1);
ServletOutputStream sout = response.getOutputStream();
int c;
while((c=in.read())!= -1)
sout.write(c);
in.close();
sout.flush();
sout.close()
}catch(Exception e)
System.out.println("error in selectValue the error is "+e);
finally
rs .close( );
sm .close( );
Lcon.close( );
public Connection getConntcion()
Connection con = null;
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection(",,,,,,,, DB Info ,username and password ,,,,,,,,,,,");
}catch(Exception e)
System.out.println("error in connection the error is "+e);
return con;
Jsp code :
<%@ page contentType="text/html"%>
<html>
<head
</head>
<title> testing image </title>
<body>
<form>
<img src="servlet/Servlet?no=2">
</form>
</body>
</html>InputStream in = rs.getBinaryStream(1);
byte[] image= null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[8192];
int bytesRead = 0;
while ((bytesRead = in.read(buffer, 0, 8192)) != -1)
baos.write(buffer, 0, bytesRead);
image= baos.toByteArray();
in.close();
ServletOutputStream sout = response.getOutputStream();
if (image != null)
sout.write(image);
sout.flush();
} -
How can I Display a Image with tiff format in Jpanel?
How can I Display a CMYK Image with tiff format in Jpanel ? Not in ScrollingImagePanel? Thank you in advance.
Why nobody can help me?I am very anxious!help me,please!
-
I want to display the image with the help of servlet by specifying the url
hi all,
I am getting the Image from the Server to the Servlet (when i am using the physicalAddress ie c:/programfiles/......)it was getting the image but at the same time it was not displaying the image when i am using the URL address(ie http://localhost:8080/....)it was not displaying the image.
I don't know what the problem is...what is the problem?
can anybody give me the suggestion for fixing that.
thanks in advance
lakshmanHi,
Invoice you will have the Purchase Order no. Display the purchase order through ME23N and at the item details you can find the GRN No. Or double click on the purchasing doc no. system will display the PO.
Thanks
VK -
How do I get picture control to display PNG images with transparent background?
I have an image of a robot arm looking from the top with a transparent background and saved as PNG. When I drag the image directly to LabVIEW front panel, the image shows properly with the transparent background, but I want to manipulate it such as rotate the image. I used the Read from PNG.vi to read the image to a picture control, but the background isn't transparent anymore. Am I missing something?
Please help.unclebump gets 5 stars for referring you to a document that I wrote.
Incidentally, I wrote it years back, for LabVIEW 7.0. A couple of notes to summarize:
The picture control doesn't "really" support transparency. However, the image data type supports masking, and stores the alpha channel, if present in your image data. So you use the "Create Mask By Alpha.vi" referenced in that document to mask out pixels whose transparency is above a certain level. It does not support partial transparency. You could try to implement your own blending algorithm based on the picture control's current pixel values, and the image data's RGB value and transparency value, but it would probably be very slow.
Also, that VI ships with 8.0 and later. I don't know if it's on the palettes but it lives here: vi.lib\picture\picture.llb\Create Mask By Alpha.vi
Good luck! -
Problem with display an image on JFrame in Java 6
I'm trying to display an image on JFrame in this way:
1.) I'm creating a variable in the class:
private Image imgSpeaker = null;2.) I'm overiting the paint method:
public void paint(Graphics g) {
super.paint(g);
g.drawImage(imgSpeaker, 330, 230, null);
}3.) In the constructor I'm using this code:
imgSpeaker = Toolkit.getDefaultToolkit().getImage("D:\\speaker.gif");
MediaTracker trop = new MediaTracker(this);
trop.addImage(imgSpeaker,0);
try {
trop.waitForID(0); // waiting untill downloading progress will be complite
} catch (Exception e) {
System.err.println(e);
} The Image will be displayed on form, but if I catch the window and move it (for example: down as possible)
the image is not refreshed (repainted). What I'm doing wrong? I've been used this solution in Java 5 and everything
works perfectly. Any of described methods aren't depricated... Anyone can help me?Thanks for your code, I've been tryed to apply your solution (with create a Buffered Image), but it still not working correctly. Firstly, the image isn't loading, and secondly the basic problem is not give in. Why have you been using "bg2d.draw(img, x, y, w, h, frame);" not in the paint method?
I'm use "Free Design" layout. Below I put on completly code from Netbeans.
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.image.BufferedImage;
public class ImageTest extends javax.swing.JFrame {
private Image imgSpeaker = null;
private BufferedImage bi = null;
private MediaTracker trop = null;
public ImageTest() {
initComponents();
trop = new java.awt.MediaTracker(this);
imgSpeaker = java.awt.Toolkit.getDefaultToolkit().getImage("D:\\speaker.gif");
try {
trop.addImage(imgSpeaker, 0);
trop.waitForID(0);
} catch (java.lang.Exception e) {
java.lang.System.err.println(e);
bi = new java.awt.image.BufferedImage(100, 100, java.awt.image.BufferedImage.TYPE_INT_RGB);
java.awt.Graphics2D bg2d = (java.awt.Graphics2D) bi.createGraphics();
trop.addImage(bi, 1);
// java.io.File f = new java.io.File("D:\\speaker.gif");
// try {
// bi = javax.imageio.ImageIO.read(f);
// } catch (IOException e) {
// java.lang.System.err.println(e);
public void paint(Graphics g) {
// super.paint(g);
try {
trop.waitForAll();
} catch (Exception e) {
System.err.println(e);
g.drawImage(bi, 50, 100, imgSpeaker.getHeight(this), imgSpeaker.getHeight(this), this);
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("jButton1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(283, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(44, 44, 44))
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(252, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(25, 25, 25))
pack();
}// </editor-fold>
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ImageTest().setVisible(true);
private javax.swing.JButton jButton1;
} -
Displaying an image in jsp / servlet
Hi, I am trying to display an image from database to be displayed in the servlet
following is my code
package image;
import java.io.*;
import java.text.*;
import java.util.*;
import java.sql.*;
import java.awt.*;
import java.awt.image.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.PrintWriter;
import com.sun.image.codec.jpeg.*;
public class BlobImageServlet extends HttpServlet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
String idStr="";
String buffString="";
InputStream is;
byte[] buffer=null;
Connection conn = null;
//Statement stmt =null;
CallableStatement stmt;
ResultSet rs;
//BlobStudentInfo bInfo = null;
//Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
//idStr = (String)request.getParameter("id");
//bInfo = (BlobStudentInfo)request.getAttribute("binfo");
try {
//stmt = conn.getConn().createStatement();
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
conn = DriverManager.getConnection("jdbc:sybase:Tds:dbserv.com.xyz.edu:4444/mydb","user","pwd");
stmt = conn.prepareCall("{call dbo.getimage(?)}");
stmt.setInt(1,10);
stmt.execute();
stmt.getMoreResults();
rs = (ResultSet) stmt.getResultSet();
while (!rs.isFirst()) {
rs.next();
buffer = rs.getBytes("image");
// rs = stmt.executeQuery("select image from photo where indexing =10");
if (rs.equals(null)){
System.out.println("Resultset is not null");
}else System.out.println("RS is not null");
//while (rs.next());{
// buffer = rs.getBytes("image");
stmt.close();
rs.close();
//conn.closeConnection();
} catch(SQLException sqe){
while (sqe != null) {
System.out.println("BlobImageServlet: SQLException: " + sqe.getMessage());
//e.printStackTrace();
sqe = sqe.getNextException();
} catch (Exception e) {
System.out.println("BlobImageServlet: Exception !!");
e.printStackTrace();
//buffer = bInfo.getHeadshot();
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(new ByteArrayInputStream(buffer));
BufferedImage image = decoder.decodeAsBufferedImage() ;
response.setContentType("image/jpeg");
// Send back image
ServletOutputStream sos = response.getOutputStream();
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
encoder.encode(image); // writes the image to browser
} //doPost closed
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
doPost(request, response);
and the corresponding procedure is
create procedure dbo.getimage
@indexing int
as
select image from dbo.photo where indexing = @indexing
Whenver I try to run the servlet as http://localhost:8080/Test/BlobImageServlet
I get null pointer exception
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:89)
image.BlobImageServlet.doPost(BlobImageServlet.java:72)
image.BlobImageServlet.doGet(BlobImageServlet.java:86)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
Please let me know if you have any questions.When we see the following code
response.setContentType("image/jpeg");
we can only view the images from database that were stored of jpeg but not of gif.
Like gif images stored in binary format doesnt allow us to view back the images instead give some exceptions like
com.sun.image.codec.jpeg.ImageFormatException: Not a JPEG file: starts with 0x42 0x4d
sun.awt.image.codec.JPEGImageDecoderImpl.readJPEGStream(Native Method)
sun.awt.image.codec.JPEGImageDecoderImpl.decodeAsBufferedImage(JPEGImageDecoderImpl.java:210)
image.BlobImageServlet.doPost(BlobImageServlet.java:67)
image.BlobImageServlet.doGet(BlobImageServlet.java:80)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
If I have to veiw a gif image from the database it doesnt allow me to do so giving jpeg exceptions.
I have put a javascript asking the uploaders to load only jpeg files.
but i would be happy if it was generic. Is there any solution.
Regards
Sandeep. -
hi,
i am trying to display an image in a form. The code worked fine in j2me emulator, but when i converted the program to a jar and ran the same program in my mobile phone.
i get an exception in Image.createImage(.. method
and exception value is just null.
i know the image is not found in the specified location. but the image is there in the jar file.
how do i solve this issue?
thanks in advance.Its definitly the heap size image, it can be case that image size is very large, u just try by optimizing the image and decreasing the size of image,
or
the image size(widht*height) is larger than actual phone screen
try with small image(small width*height) you will come to know the problem
@rjun -
Connecting and showing video image with activeX
Hello,
I''m currently working on a student project. The project revolves around connecting an ip camera in LabView. I have recieved a SDK from the company that deliver the camera. There are several activeX methods in this package. The camera require that you supply it with certain information like ip-adress, user, password and other. All this i found in the SDK and seem to work. The problem comes when I'm trying to display the image from the camera. I can't seem to find a activeX component to do this task. Is it supposed to be there in the SDK or is it a function/method in LabView that can display the image. I have tryed to connect IMAQ to the activeX components, but the whires missmatch. So I am kinda blank on what to do, any help will be appritiated..
regards
VediHello Kudo
I have tested your MSVidCtl.EXAMPLE.llb to see if I could use it to get 1600x1200 wmv video into labview
in 8.5 and get it to work with a short wmv sequence that I have collected using a logitech 9000 camera at 480x640 resolution.
Then I tested with max resolution 1600x1200 but the images comes not out correctly , but then I look at the property for MSVidCTl and specially I look for the property browser for the frontpanelobject for MSVidCtl where the image appears and change the property "actual size" to true (default false) and then it works !!! (Now the whole image come out in original 1600x1200 and correctly)
Thanks a lot
Now to my real question:
Can I now in Labview be able to " programmatically snap individual frames from the video that I see from the MSVidCTL window using 8.5 native commands ?. I want to use the "picture control " for furthe analyze.
Thanks again for providing this very good example code !
Kind Regards Lars
Attachments:
640x480wmvvideo.png 86 KB
1600x1200videosuccessafterchangingpropertybrowserautosizetotrue.png 43 KB -
Display incomplete image: Premature end of JPEG file
Hello people,
My problem is that displaying an image with incomplete data works fine, apart from that the following error message is printed out: Premature end of JPEG file
The picture looks perfect (the missing part is rendered in gray), but I want to get rid of the error message.
//init
File jpegFile = new File("picture.jpg");
FileInputStream inputStream = new FileInputStream(jpegFile);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
//step 1: downloading the image
byte buffer[] = new byte[bufferSize];
int bytesRead;
while( bytesRead = input.read( buffer ) ) >= 0 )
output.write( buffer, 0, bytesRead );
//step 2: create (and display) incomplete image (download not finished yet)
byte byteArray[] = outputStream.toByteArray();
Image img = Toolkit.getDefaultToolkit().createImage( byteArray );Thanks for help,
MartinRecreate the JPG image in your graphics editor - it is
corrupted.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"wuest" <[email protected]> wrote in message
news:e20uth$pme$[email protected]..
> Have just used the assets panel for the first time...
tried to create a
> template... an image showed up and then this unending
message kept
> appearing
> ... "premature end of jpeg file" and no matter how many
times you click it
> stil
> keeps reappearing... please, can someone put me out of
my misery?
>
> thanks.
> -
Display an image in a new window
I am trying to display an image when certain criteria is met. How can I either open the image to a new window jsut displaying the image or just have the image pop up in the window that is already open.
ThanksA simple solution would be to use a case selection so that when you criteria has been met
then a VI pops ups with image .
Use an exit button to terminate VI(close ).
chow
xseadog -
I am trying to load and display multiples images with a Loader, one after another. The program only displays the last image to be loaded and added to the stage. What is wrong? Here is my code..
---START OF CODE---------------------------------------
import flash.events.MouseEvent; //Package needed for mouse events
btnGenerate.addEventListener(MouseEvent.MOUSE_DOWN, buttonPressed); //Button click listener
chkSeal.addEventListener(MouseEvent.MOUSE_DOWN, chkTriggered); //Check box click listener
//If the check box is toggled, switch to 8 or 9 max characters
function chkTriggered(event:MouseEvent):void
if (chkSeal.selected == false)
txtInput.maxChars = 8;
else
txtInput.maxChars = 9;
function buttonPressed(event:MouseEvent):void
var pictureLoader:Loader = new Loader(); //Picture loading variable
var plateText:String = txtInput.text; //Plate text string
var filename:String; //Filename for each character's associated picture
var currentX:int = 10; //Current x position
var i:int; //Counter to use in for loop
plateText = plateText.toUpperCase(); //Convert plate text to upper case
//For every character in the sequence
for(i = 0 ; i < txtInput.length ; i++)
filename = "/Numbers and Letters/" + plateText.charAt(i) + ".png"; //Generate filename
pictureLoader.load(new URLRequest(filename)); //Load the picture
addChild(pictureLoader); //Add picture to the stage
pictureLoader.x = currentX; //Move picture into position
pictureLoader.y = 366; //Constant y position for all images
currentX = currentX + 52; //Increase the current x (by the size of the images)
txtInput.text = "Done!"; //Display done in the text box
-------------END OF CODE----------------------------You appear to only have one Loader instance working for you. A Loader can only hold one load at a time. Try creating new Loaders within the loop.
-
Manipulating (Rotating) an Image with a button in Java
I'm trying to display an image in a BorderLayout, and also I want a button on the layout that, when pressed, will rotate the image. I'm not sure how to create an image and be able to add it to a JFrame because when I do so, using something like:
Image img = new Image("myPic.gif");
myFrame.add(img, BorderLayout.CENTER);
I just end up getting a compiler error. I could use a seperate class and draw the image in the paintComponent method, but I'm not sure how I add both the image and a button with which I can manipulate the image in the same class (I am assuming I need to use an ActionListener on the button to control the image, and if this is the case I am assuming they need to be in the same class). Can someone point me in the right direction here?
Thanks,
Alex
[email protected]put the image in a JPanel subclass as you mention above and have a public method in this class that rotates the image. Then just have the button call this object's rotate method. OOP to the rescue.
Maybe you are looking for
-
Document Name on Print in Adobe Reader 9
How can I add the document name to a document printed from Adobe Reader 9 (using Microsoft Windows XP 2002)?
-
Querying value from a range of two values
I have patched together a shopping cart, operating on CF8, and am now trying to add shipping. The client wants the shipping charges based on the cost of item, ie: 0-$499 is $20 $500 – $999 is $25.00 $999 – up $45 I built an access table (simplified
-
Can I call a C function from Java (using JNI) ??
hello, I need to call one C function from remote device and get its return value(o/p) (for my application it is device SSID ) and display in the client PC. Is it possible in java without using SNMP connction?. please give me idea about it. I need thi
-
BI : Mapping tranformations
Hi Gurus , I have created an ODS ZBCKSPLT (target) which should be mapped to two cubes ZPS_C04(Source) & 0PS_C04(Source). There is field ZOPENORSP ,0OPENORDVAL , ZINVSPLT in ZBCKSPLT which should be populated. but the problem is there is no source
-
ASSERTION_FAILED runtime error
Hi, We are working on BI7.0 and updated the patches just yesterday to Support Package 17. Today i tried to upload the data we got the short dump ASSERTION_FAILED error. I checked on SDN , there were suggestion to apply note 998730. in that we have to