Como criar thumbnails em Java ME
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot addition of Template:ArticleMetaData) |
|||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | Para criar um thumbnail a partir de uma imagem maior, use o código a seguir. | + | {{ArticleMetaData |
| + | |sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] --> | ||
| + | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> | ||
| + | |devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') --> | ||
| + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> | ||
| + | |platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later --> | ||
| + | |devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | ||
| + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | ||
| + | |signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> | ||
| + | |capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| + | |keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase --> | ||
| + | |id= <!-- Article Id (Knowledge base articles only) --> | ||
| + | |language=Lang-Portuguese | ||
| + | |translated-by= <!-- [[User: XXXXX]] --> | ||
| + | |translated-from-title=<!-- Title only --> | ||
| + | |translated-from-id= <!-- Id of translated revision --> | ||
| + | |review-by=<!-- After re-review: [[User:username]] --> | ||
| + | |review-timestamp=<!-- After re-review: YYYYMMDD --> | ||
| + | |update-by=<!-- After significant update: [[User:username]]--> | ||
| + | |update-timestamp=<!-- After significant update: YYYYMMDD --> | ||
| + | |creationdate=20071126 | ||
| + | |author=[[User:Dcrocha]] | ||
| + | }}Para criar um thumbnail a partir de uma imagem maior, use o código a seguir. | ||
<code java> | <code java> | ||
| Line 32: | Line 54: | ||
</code> | </code> | ||
| − | + | Você pode utilizar também: | |
http://www.java-tips.org/java-me-tips/midp/how-to-implement-oom-in-and-oom-out.html | 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 | + | 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]]. | Para mais detalhes, veja [[Thumbnail_path_for_3rd_edition_devices]]. | ||
| − | [[Category: | + | [[Category:Java ME]][[Category:Code Examples]][[Category:Lang-Portuguese]] |
Latest revision as of 07:24, 10 November 2011
Dados do artigo
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.

