-
This is default featured slide 1 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by NewBloggerThemes.com.
-
This is default featured slide 2 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by NewBloggerThemes.com.
-
This is default featured slide 3 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by NewBloggerThemes.com.
-
This is default featured slide 4 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by NewBloggerThemes.com.
-
This is default featured slide 5 title
Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by NewBloggerThemes.com.
Hola y lo nuevo
imágenes en java
El Problema: Si te devuelve -1, significa que no pudo obtener el tamaño, es porque no se cargo la imagen aún
Estas cargando las imágenes de la siguiente manera:
Image imgen = Toolkit.getDefaultToolkit().getImage( getClass().getResource("objeto.jpeg") ); int ancho = imgen.getWidth(null); int alto = imgen.getHeight(null); System.out.println("ANCHO:"+ancho+" ALTO:"+alto);
La salida es algo como:
ANCHO:-1 ALTO:-1
Esto es porque Toolkit.getDefaultToolkit().getImage() retorna primero y luego empieza a cargar los pixels.
Solución:
Utilizar la Clase Image Icon para cargar ya que este método retorna cuando se termino de cargar la imagen.
Image imgen = new ImageIcon(getClass().getResource("imagen.gif")).getImage(); int ancho = imgen.getWidth(null); int alto = imgen.getHeight(null); System.out.println("ANCHO:"+ancho+" ALTO:"+alto);
La salida es algo como:
ANCHO:50 ALTO:50