Problem loading & displaying images from URL
hi,
I can't manage to display an image into a component from a url... here is what my code looks like :
public class ImageComponent extends JComponent{
private ImageIcon imageIcon;
public void paint(Graphics g){
if(imageIcon!=null){
imageIcon.paintIcon(this, g, posX, posY);
private void loadsImage(String imageURL){
imageIcon = new javax.swing.ImageIcon(imageURL);
invalidate();
}when I call loadImage with a proper url, the image doesn't seem to be loaded...
it might be that the image is big and long to come (also my connection isn't that fast)... but forcing the repaint of the component (by hiding/showin the component's window) after a good while doesn't do much...
can anybody tell me where I'm doing wrong...
cheers,
DrLeinster
hi,
looks like PaintComponent() instead of paint did the job.
thanks a million..
for those interested in loading images, I find ImageIcon very limited and at the end I found a better solution :
public class ImageComponent extends JComponent implements ImageObserver{
private Image image;
public void loadImage(URL imageURL){
image = Toolkit.getDefaultToolkit().getImage(imageURL);
prepareImage(image,getWidth(),getHeight(), this);
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height){
System.out.print("."); // loading progress...
public void paintComponent(Graphics g){
if(image!=null){
g.drawImage(image,0,0,null);
}it is far nicer as it displays dots while loading... up to you to attach progress bars or favorit loading guizmo...
DrLeinster.
Similar Messages
-
Displaying images from url's (9i)
Is it possible to some how display images retrieved from a url within an image item? I know its possible to display images from within the database and from a file but these images are stored on another server and all i have is a web address, can it be done? Also is it possible to dislpay a series of images that are retrieved in this way in a report?
Any help is much appreciated.Hi,
this would require a Java Bean to be written. Its not natively possible in Forms
Frank -
Displaying images from url connection
I'm working on an application that extracts information from html content (textual, colors, images...) and evaluates rates of emotion and personality.
I need to access and display images contained in a web page.
How can I add an image to a pane and display it knowing its url,
for example I want to display image.jpg knowing http://www.website.com/image.jpgThe ImageIcon class in javax.swing can accept a URL in the constructor:
public ImageIcon(URL location) -
Hi Experts,
I am new to BSP. I have a requirement like I need to display an image which is stored in a url. The URL will be changed depending on the document no.
Please suggest how can I display the image on BSP dynamically based on the document no? I will get the URL from a table.
Thanks in advance.
Regards,
Ranganadh.Hi Ranganadh,
You can use a variable to hold the URL type string.
Populate the url into the variable from table like
<%
data lv_url type string.
select URL from URL_TABLE into lv_url where document_no = 'xyz'.
%>
Same can be passed to the image source attribute
img src = "<%= lv_url %>"
Regards,
Ravi -
Problem to display image from database
i also waiting when this practical will come to the end la..really boring..mrhanafi came 2 weeks ago..he didnt check anyhting..he was there for 15 mins only..hey dont play ponteng la..after this friday you ponteng how many days you want;)
Using JHeadstart, you can display a BLOB column from the database in HTML, by way of ADF. Check out the JHeadstart Tutorial at http://www.oracle.com/technology/products/jdev/tips/muench/jhstutorial/index.html to get started, then do the same for your own database tables that include the BLOB column. JHeadstart will take care of rendering it as a file upload or image, depending on the display type you set at the attribute level.
Hope this helps,
Sandra Muller
JHeadstart Team
Oracle Consulting -
How to display image from wamp if the data type i use is blob?
please help me with the problem of displaying image from wamp if data type is blob. Thanks
Don't store the images in the database. Store the image file names in the database and put the images in a folder.
-
Problem Displaying image from blob
Hi all,
I m using,
Database : 10g Rel 2
Frontend : DevSuite 10g
OS : WinXp
Browser : IE 6
Problem : In my forms i m displaying images from blob column but some of the images are not displayed. I have tried with all image formats available in combination with all available display quality but no luck. What could be the reason for it and how do i solve it?
Can anyone help me plz?
Thnx in advance.
ImtiazHello,
It is very difficult for us to "guess" what images you can read and what others you cannot.
Maybe you could provide more information on images that are not displayed ?
What is their native format ?
Francois -
Problem Loading an Image with javax Swing from a JApplet
First of all, i use JCreator as java creater and have the newest version of java sdk version.
Now i need to load an image from the harddrive on which the JApplet is located. I need to do this from inside the JApplet. I have put my pictures in a map 'images' which is located in the same directory as the classes + htm file. It works from inside JCreator, but as soon as i open the normal htm it just WON'T load that image (grmbl).
Here is my code for loading the image:
public BufferedImage loadImage (String filename, int transparency)
Image image;
if (app)
image = Toolkit.getDefaultToolkit().getImage(("./images/"+filename));
else
String location = "";
location = "./images/"+filename;
image = Toolkit.getDefaultToolkit().getImage(location);
MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(image, 0);
try
mediaTracker.waitForID(0);
catch (Exception e)
Could anybody help me out here??
I tried a url already using getCodeBase() or getDocumentBase() but that gives an error because it cannot find those if using a JApplet.Why don't you use javax.swing.ImageIcon? If you already have a flag telling if it's an application or applet, use the getDocumentBase() to base the URL in the applet part only.
-
Loading an image from an arbitrary URL without using an ImageIcon
Can anybody maybe point me in the direction of other (as in harder-to-use, but more flexible) ways to load an image from a URL?
Interesting results:
When I run this test code (the names have been changed to protect the innocent):
package graphicstest;
import javax.swing.*;
import java.net.*;
import javax.imageio.*;
import java.awt.image.*;
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2007</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
public class Foo
extends JFrame {
static ImageIcon ii;
public Foo() {
setSize(200,200);
try {
System.out.println("2=aborted; 8=complete; 4=errored; 1=loading");
ii = new ImageIcon(new URL("http://intranet/part?FOO.JPG"));
System.out.println("image load status: " + ii.getImageLoadStatus());
getContentPane().add(new JLabel(ii));
System.out.println("image load status: " + ii.getImageLoadStatus());
}catch(Throwable t) {t.printStackTrace();}
public static void main(String args[]) {
Foo foo = new Foo();
foo.setVisible(true);
if (ii.getImageLoadStatus() == 4) {
try {
BufferedImage bi = ImageIO.read(new URL(
"http://intranet/part?FOO.JPG"));
ii.setImage(bi);
foo.validate();
foo.repaint();
} catch(Throwable t) {t.printStackTrace();};
}. . . from a box that's not on the VPN, it blows up at the ImageIO.read() call (not unexpectedly). But if I run it from a box that's on the VPN, and able to access the URL, then it returns just fine from the ImageIO.read(), and I get a null pointer exception at the call to setImage().
Clearly, this is trying to tell me SOMETHING, but I don't quite know WHAT.
JHHL -
Loading an Image from the database and display it on browser
I do not know if this is even possible.
At the moment, to load an image inside an Html page you need to use the <img src=""> tag. and in the src you put the path of the image. Now I would like to save an image inside the database.
An option to still display the image on the browser would be that my service object, would load the object from the database (saved as blob) then save it somewhere on the Server, and the still use the <img> tag to load the image from that location.
However I was wondering wheather there is another way to do it without saving this image on the server. that is loading the bytes from the database (or a location on the server) and provided these bytes to the jsp page to display the image.
Is this possible? or?
regards,
sim085hmm ... ok .. that sounds good .. but that means that
a servlet must exsist at all time to display the
required image.Servlets are usually instantiated by the servlet container upon an incoming request. -
Error While loading a image from database
Purpose
Error While loading the Image from the database
ORA-06502: PL/SQL : numeric or value error:Character string buffer too small
ORA-06512: at "Sys.HTP" ,line 1480
Requirement:
I am developing the web pages using PSP(Pl/sql Serverpages) . I have a requirement to show a image in the webpage. I got the following procedures from the oracle website.
I have created the following table to store the images
create table DEMO
ID INTEGER not null,
THEBLOB BLOB
And I also uploaded the Images. Now I am try to get a image from the table using the following procedure .But I am getting the error message line 25( htp.prn( utl_raw.cast_to_varchar2( l_raw ) );) .at it throws the following error messages
ORA-06502: PL/SQL : numeric or value error:Character string buffer too small
ORA-06512: at "Sys.HTP" ,line 1480
Procedure that I used to get the image
create or replace package body image_get
as
procedure gif( p_id in demo.id%type )
is
l_lob blob;
l_amt number default 30;
l_off number default 1;
l_raw raw(4096);
begin
select theBlob into l_lob
from demo
where id = p_id;
-- make sure to change this for your type!
owa_util.mime_header( 'image/gif' );
begin
loop
dbms_lob.read( l_lob, l_amt, l_off, l_raw );
-- it is vital to use htp.PRN to avoid
-- spurious line feeds getting added to your
-- document
htp.prn( utl_raw.cast_to_varchar2( l_raw ) );
l_off := l_off+l_amt;
l_amt := 4096;
end loop;
exception
when no_data_found then
NULL;
end;
end;
end;
What I have to do to correct this problem. This demo procedure and table that I am downloaded from oracle. Some where I made a mistake. any help??
Thanks,
NatsHi Satish,
I have set the raw value as 3600 but still its gives the same error only. When I debug the procedure its throwing the error stack in
SYS.htp.prn procedure of the following line of code
if (rows_in < pack_after) then
while ((len - loc) >= HTBUF_LEN)
loop
rows_in := rows_in + 1;
htbuf(rows_in) := substr(cbuf, loc + 1, HTBUF_LEN);
loc := loc + HTBUF_LEN;
end loop;
if (loc < len)
then
rows_in := rows_in + 1;
htbuf(rows_in) := substr(cbuf, loc + 1);
end if;
return;
end if;
Its a system procedure. I don't no how to proceed .. I am really stucked on this....is their any other method to take picture from the database and displayed in the web page.....???? any idea..../suggesstion??
Thanks for your help!!!. -
Loading realscale image from memorycard.
Hi.
I made a big image (3550 x 2100 pixels), which my Nokia 6125 didn't zoom enough on the normal Picture preview.
So I decided to make a program for it, so I could see all the details from the pic, and move around on the image. (Like zoom, but I need to get closer.. )
First problem i encountered, was that 4mb application was too big to install on my memorycard... Darn limits...
So I decided to add them seperately, that I'd load the image from the application.
Well when I ran the "File Browser", there was 3 things:
- ".." (Folder up)
- "E:\" (crashes, no access)
- "C:\" (crashes, no access)
So any ideas how could I get it work properly?
Thanks!hmm ... ok .. that sounds good .. but that means that
a servlet must exsist at all time to display the
required image.Servlets are usually instantiated by the servlet container upon an incoming request. -
Dear JSP/Servlet experts,
I have problem in displaying images on a JSP page. I stored all the images names in a database and
try to retrieve them based on the user selection. When the JSP page is load for the first time the
following error occur but the images are displayed correctly:
2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover150.jpg + null) Connection aborted by peer: socket write error
2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover154.jpg + null) Connection aborted by peer: socket write error
2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover152.jpg + null) Connection aborted by peer: socket write error
2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover151.jpg + null) Connection aborted by peer: socket write error
2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover156.jpg + null) Connection aborted by peer: socket write error
Here is the code to display the images(the getCover() method will return cover150.jpg, cover151.jpg.... )
and the images are stored in /simple/images folder
<td><a href="<img src="/simple/images/<%= b.getCover() %>" alt="details"></td>try this
<img src=/simple/images/<%=b.getCover() %>
vasanth -
I want to save images to memory 50 images
My software processing ----
1. Download Image from URL every 60 secs and all downloaded images have time to use 15 mins
2. When download image done save images to memory
3. Then show images in picturebox
4. When user click button get next image form memory and delete old image from memory
5. If what images not use in 15 mins auto delete from memory
Help me ... Thank you a lotOk chechk the below method/Events that will download 50 image and fill a List<image> object into memory, you need to add a picturebox1 and button1 to your form, I used my profile pic here on msdn the link you've send didn't work:
//Global Variables
List<Image> li = new List<Image>();
int second = 0; //Form Initaile
public Captcha()
InitializeComponent();
//Async download event
private void ReadCallback(IAsyncResult asynchronousResult)
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
using (StreamReader streamReader1 = new StreamReader(response.GetResponseStream()))
li.Add(Image.FromStream(streamReader1.BaseStream));
pictureBox1.Image = li[0];
//Download Method for 50 images
private void DownLoadImages()
try
for (int i = 0; i <= 50; i++)
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri("https://i1.social.s-msft.com/profile/u/avatar.jpg?displayname=fouad%20roumieh&size=extralarge&version=00000000-0000-0000-0000-000000000000"));
request.BeginGetResponse(new AsyncCallback(ReadCallback), request);
catch (WebException ex)
//Form Load
private void Captcha_Load(object sender, EventArgs e)
DownLoadImages();
And here on button click event we remove element and show the next one into picture box, and if used up all image we call the async download messages again to get a new list of images:
private void button1_Click(object sender, EventArgs e)
li.RemoveAt(0);
if (li.Count > 0)
{ //Show next
pictureBox1.Image = li[0];
else
DownLoadImages();
Also here a timer event I didn't enable but you can enable to check for the 15 mins and destroy the images list if passed:
private void timer1_Tick(object sender, EventArgs e)
second = second + 1;
int minutes = second / 60;
if (minutes >= 15)
li.Clear();
//Call downloadimages or else...
Fouad Roumieh -
Adding a layer with image from URL
I am trying to write a script that adds a layer to a document, and loads an image from a url such as "http://fantasy411.mlblogs.com/ron-burgundy.jpg" .
How can I go about doing this? Thanks in advance.If you have a newer version of Photoshop that supports sockets you can do something like this.
// openImageFromWeb.jsx
// Copyright 2006-2009
// Written by Jeffrey Tranberry
// Photoshop for Geeks Version 3.0
// modified by MLH
Description:
This sample script shows how to download images from a web server using the
Socket object.
// Note: Socket.read() parameter & behavior
// Socket.read() will read or time out. It may not read all data fromserver.
// Socket.read(999999) will read 999999 bytes, or timeout, or socket will be
// closed by the server.
// enable double clicking from the
// Macintosh Finder or the Windows Explorer
#target photoshop
// Make Photoshop the frontmost application
app.bringToFront();
// SETUP
var socket = new Socket;
var html = "";
var domain = "www.adobe.com" // the domain for the file we want
var sImg = "/ubi/globalnav/include/adobe-lq.png"; // the rest of the url for the file we want
var port = ":80"; // the port for the file we want
// MAIN
var f = File("~/socket_sample_" + sImg.substr(sImg.length-4)); // 4 = .gif or .jpg
f.encoding = "binary"; // set binary mode
f.open("w");
if (socket.open(domain + port, "binary")){
// alert("GET " + sImg +" HTTP/1.0\n\n");
socket.write("GET " + sImg +" HTTP/1.0\n\n"); // get the file
var binary = socket.read(9999999);
binary = removeHeaders(binary);
f.write(binary);
socket.close();
f.close();
if(app.documents.length == 0) app.documents.add(new UnitValue(200,'px'), new UnitValue(200,'px'), 72, 'Untitled 1');
placeSmartObject( f );
f.remove(); // Remove temporary downloaded files
// FUNCTIONS
function placeSmartObject(fileRef){
//create a new smart object layer using a file
try {
var desc = new ActionDescriptor();
desc.putPath( charIDToTypeID( "null" ), new File( fileRef ) );
desc.putEnumerated( charIDToTypeID( "FTcs" ), charIDToTypeID( "QCSt" ),charIDToTypeID( "Qcsa" ));
desc.putUnitDouble( charIDToTypeID( "Wdth" ),charIDToTypeID( "#Prc" ), 100 );
desc.putUnitDouble( charIDToTypeID( "Hght" ), charIDToTypeID( "#Prc" ), 100 );
desc.putUnitDouble( charIDToTypeID( "Angl" ), charIDToTypeID( "#Ang" ), 0 );
desc.putBoolean( charIDToTypeID( "Lnkd" ), true );
executeAction( charIDToTypeID( "Plc " ), desc, DialogModes.NO );
activeDocument.activeLayer.resize(100 ,100,AnchorPosition.MIDDLECENTER);
activeDocument.revealAll();
} catch (e) {
if (!e.toString().match(/Place.+is not currently available/)) {
throw e;
// Remove header lines from HTTP response
function removeHeaders(binary){
var bContinue = true ; // flag for finding end of header
var line = "";
var nFirst = 0;
var count = 0;
while (bContinue) {
line = getLine(binary) ; // each header line
bContinue = line.length >= 2 ; // blank header == end of header
nFirst = line.length + 1 ;
binary = binary.substr(nFirst) ;
return binary;
// Get a response line from the HTML
function getLine(html){
var line = "" ;
for (var i = 0; html.charCodeAt(i) != 10; i++){ // finding line end
line += html[i] ;
return line ;
You may have to check your firewall setting if you have one and it doesn't work with some servers. At least I can not get it to work with some.
Maybe you are looking for
-
I can't connect to MySQL database from The JSP Standard Tag Library
Hi All ! I have a problem, please help me anybody ! I don't connect to MySQL database from jsp page using JSTL tag but from servlet all work correctly. I set my path and put �mysql-connector-java-3.1.13-bin.jar� in ENVIRONMENT WinXP(classpath=C:\Java
-
Sending pdfs from Mac Mail to Outlook
I have users that are sending pdfs from mac mail to outlook and the attachements are not going through. All you see is the paperclip and nothing else. This has just started happening. I am telling the users to send emails as plain text with window
-
How to make JScrollPane scroll faster?
Hi, I have tried to develop on a program to zoom in or zoom out the image�a graph which is plotted using the method draw from Graphics2D. In the program, I am given about 1000 points, which are supposed to be plotted one by one suing the draw method,
-
How do I get CC to open these files correctly? Is the client saving them incorrectly? My work around has now become a pain & I need to know why Illustrator CC tells me most/all embedded images are missing in files received by clients. Illustrator 5.1
-
Error msg "no modem found!" when trying to connect...
Hi. I'm getting this error message when I tried to connect to N95 via bluetooth as modem, using "One Touch Access". I can use "One Touch Access" to connect with N95 via USB cable, though. My hardware is: Toshiba R150 laptop; Generic bluetooth adaptor