Merhaba arkadaşlar, java özellikli cep telefonları için bir j2ME oyunu üzerinde çalışıyorum. Aşağıdaki yöntemi ile şeffaf PNG ölçeğe çalışılıyor:Bir PNG'yi yeniden ölçeklendirmek için özel yöntem saydamlığı kaybediyor
// method derived from a Snippet from http://snippets.dzone.com/posts/show/3257
// scales an image according to the ratios given as parameters
private Image rescaleImage(Image image, double XRatio, double YRatio)
{
// the old height and width
int sourceWidth = image.getWidth();
int sourceHeight = image.getHeight();
// what the new height and width should be
int newWidth = (int)(XRatio * sourceWidth);
int newHeight = (int)(YRatio * sourceHeight);
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 * sourceWidth)/newWidth;
int dy = (y * sourceHeight)/newHeight;
g.drawImage(image, (x - dx), (y - dy), Graphics.LEFT | Graphics.TOP);
}
}
return Image.createImage(newImage);
}
Bu doğru görüntüyü ölçekler, ne yazık ki yöntemiyle döndürülen görüntü ile şeffaflığı kaybediyor gibi görünüyor. Bu kavramlara oldukça yeniyim ve herhangi bir yardım çok takdir edilecek! 'un java özellikli bir mobil cihazda düzgün bir şekilde görüntülenmesi için, yeniden boyutlandırmanın herhangi bir görüntü düzenleyicide değil kodda yapılması gerekir.
Şimdiden teşekkürler!
Bu yöntemin J2ME'de desteklendiğini düşünmüyorum, yine de cevabınız için teşekkürler! – jbabey
Benim hatam, başka bir cevap gönderecek. –