×
Namespaces

Variants
Actions
(Difference between revisions)

Como criar thumbnails em Java ME

From Nokia Developer Wiki
Jump to: navigation, search
thiagobrunoms (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Automated change of category from Lang-PT to Unlikely Category. (Moving))
Line 39: Line 39:
 
Para mais detalhes, veja [[Thumbnail_path_for_3rd_edition_devices]].
 
Para mais detalhes, veja [[Thumbnail_path_for_3rd_edition_devices]].
  
[[Category:Java_ME_(Português)]][[Category:Exemplos de código Java ME]][[Category:Lang-PT]]
+
[[Category:Java ME]][[Category:Code Examples]][[Category:Lang-Portuguese]]

Revision as of 08:16, 14 July 2011

Para criar um thumbnail a partir de uma imagem maior, use o código a seguir.

private Image createThumbnail(Image image) {
int sourceWidth = image.getWidth();
int sourceHeight = image.getHeight();
 
int thumbWidth = 64;
int thumbHeight = -1;
 
if (thumbHeight == -1)
thumbHeight = thumbWidth * sourceHeight / sourceWidth;
 
Image thumb = Image.createImage(thumbWidth, thumbHeight);
Graphics g = thumb.getGraphics();
 
for (int y = 0; y < thumbHeight; y++) {
for (int x = 0; x < thumbWidth; x++) {
g.setClip(x, y, 1, 1);
int dx = x * sourceWidth / thumbWidth;
int dy = y * sourceHeight / thumbHeight;
g.drawImage(image, x - dx, y - dy,
Graphics.LEFT | Graphics.TOP);
}
}
 
Image immutableThumb = Image.createImage(thumb);
 
return immutableThumb;
}

Você pode utilizar também: http://www.java-tips.org/java-me-tips/midp/how-to-implement-oom-in-and-oom-out.html

Vale lembrar que ambos os métodos usam muita memória e processamento, sendo adequado que sejam feitos em background, em uma nova Thread. Se você está usando um dispositivo S60, você pode tentar localizar os thumbnails já gerados pela aplicação Galeria, geralmente localizados na pasta "_PAlbTN" dentro do diretório de imagens.

Para mais detalhes, veja Thumbnail_path_for_3rd_edition_devices.

60 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×