This page was last modified 16:55, 26 November 2007.
Como criar thumbnails em Java ME
From Forum Nokia Wiki
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; }
You may also use 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 um novo 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.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hablemos de J2ME en Español | ozurek | Mobile Java General | 4 | 2006-05-03 04:58 |
| Nokia 3220 problem | whichet | Mobile Java General | 3 | 2005-09-29 21:57 |
| Error in starting toolkit by Java | Nokia_Archived | General Browsing | 1 | 2002-05-15 19:01 |
| como se que he llegado a final de fichero? | jmv_ | Foro en Español (Spanish Forum) | 1 | 2007-08-22 08:21 |
| Java or C++ - what is the preferred choice for Symbian` | larry_ger | General Symbian C++ | 10 | 2004-07-14 12:40 |
