अरे दोस्तों, मैं जावा-सक्षम सेल फोन के लिए जे 2 एमई गेम पर काम कर रहा हूं। मैं निम्न विधि के साथ एक पारदर्शी PNG पैमाने पर करने का प्रयास कर रहा हूँ:एक पीएनजी को पुन: सहेजने के लिए कस्टम विधि पारदर्शिता खो देता है
// 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);
}
यह सही ढंग से छवि मापता है, दुर्भाग्य से मैं छवि विधि द्वारा दिया साथ पारदर्शिता खोने लगते हैं। मैं इन अवधारणाओं के लिए बिल्कुल नया हूं, और किसी भी मदद की सराहना की जाएगी! कृपया ध्यान दें कि पर किसी भी जावा-सक्षम मोबाइल डिवाइस पर ठीक से प्रदर्शित होने के लिए, किसी भी प्रकार के छवि संपादक में नहीं, कोड में rescaling को करने की आवश्यकता है।
अग्रिम धन्यवाद!
मुझे नहीं लगता कि यह विधि जे 2 एमई में समर्थित है, हालांकि, उत्तर के लिए धन्यवाद! – jbabey
मेरी गलती, एक और जवाब पोस्ट करेंगे। –