Показать сообщение отдельно
Старый 26.03.2009, 14:12   #5
Spiderman
Знающий
 
Аватар для Spiderman
 
Регистрация: 28.07.2008
Адрес: Киев
Сообщений: 228
Написано 61 полезных сообщений
(для 191 пользователей)
Ответ: Изменение размеров картинки

Вот примерчик нашел. Должно работать:

private Image resizeImage(Image image,int xx,int yy) {
int srcWidth = image.getWidth();
int srcHeight = image.getHeight();

int thumbHeight=10,thumbWidth=10;
int newWidth = xx;
int newHeight = yy;//-1;

if (thumbHeight == -1)
newHeight = thumbWidth * srcHeight / srcWidth;

Image newImage = Image.createImage(newWidth, newHeight);
Graphics g = newImage.getGraphics();

for (int y = 0; y < newHeight; y++) {
for (int x = 0; x < newWidth; x++) {
g.setClip(x, y, 1, 1);
int dx = x * srcWidth / newWidth;
int dy = y * srcHeight / newHeight;
g.drawImage(image, x - dx, y - dy,
Graphics.LEFT | Graphics.TOP);
}
}

Image immutableImage = Image.createImage(newImage);

return immutableImage;
}
__________________
Тяжела жизнь программиста: радость находки своего бага всегда омрачает осознание собственной тупости...
(Offline)
 
Ответить с цитированием