2011-09-18 9 views
5

मेरे पास एक ऐसा फ़ंक्शन है जो एक निर्बाध बिटमैप लेता है और इसे विश्व निर्देशांक का उपयोग करके किसी भी दिशा में स्क्रीन पर स्क्रॉल करता है। 4 ड्रॉ हैं (प्ले क्षेत्र पूर्ण बिटमैप आकार से छोटा है .. तो सबसे अधिक, आप बिटमैप की 4 प्रतियां देखेंगे, सीमलेस प्रभाव को बनाए रखने के लिए तैयार किए गए केवल अलग-अलग अनुभाग)। मैं क्या जानना चाहता हूं, क्या मुझे रेक्ट सीमाओं में संशोधन लागू करना चाहिए ताकि यह केवल उन हिस्सों को ब्लाइट कर दे जो स्क्रीन पर हो? या मुझे एंड्रॉइड को संभालने देना चाहिए? और यदि मैं इसे स्वयं करता हूं, तो मुझे इसे कैसे संभालना चाहिए? जहां तक ​​गणित जाता है, दुनिया वास्तव में मुझे भ्रमित करती है और अनुवाद करती है। :/क्या मुझे ऑफ-स्क्रीन ड्रॉ को त्यागने के लिए एंड्रॉइड पर भरोसा करना चाहिए?

यहां कोड है।

public void draw(Canvas canvas){ 

oCoords.x=(int) fX; 
oCoords.y=(int) fY; 

oTopLeft = gridContainingPoint(oCoords); 
oTopRight.x = gridContainingPoint(oCoords).x + iWidth; 
oTopRight.y = gridContainingPoint(oCoords).y; 
oBottomLeft.x = gridContainingPoint(oCoords).x; 
oBottomLeft.y = gridContainingPoint(oCoords).y + iHeight; 
oBottomRight.x = gridContainingPoint(oCoords).x + iWidth; 
oBottomRight.y = gridContainingPoint(oCoords).y + iHeight; 

canvas.save(); 
canvas.translate(-fX, -fY); 
oCloud.setBounds(oTopLeft.x, oTopLeft.y, oTopLeft.x + this.iImageWidth, oTopLeft.y + this.iImageHeight); 
oCloud.draw(canvas); 
oCloud.setBounds(oTopLeft.x + this.iImageWidth, oTopLeft.y, oTopLeft.x + (this.iImageWidth * 2), oTopLeft.y + this.iImageHeight); 
oCloud.draw(canvas); 
oCloud.setBounds(oTopLeft.x, oTopLeft.y + this.iImageHeight, oTopLeft.x + this.iImageWidth, oTopLeft.y + (this.iImageHeight * 2)); 
oCloud.draw(canvas); 
oCloud.setBounds(oTopLeft.x + this.iImageWidth, oTopLeft.y + this.iImageHeight, oTopLeft.x + (this.iImageWidth * 2),oTopLeft.y + (this.iImageHeight * 2)); 
oCloud.draw(canvas); 
canvas.restore(); 
} 

उत्तर

2

मुझे यकीन है कि मैं कोड हिस्सा द्वारा पोस्ट की गई के विवरण को समझने नहीं कर रहा हूँ, लेकिन आप पूछ रहे हैं, तो करता है एंड्रॉयड क्लिप स्क्रीन सीमा स्वचालित रूप से जवाब है हाँ करने के लिए छोड़ता है। इसलिए जब तक आप स्क्रीन के मुकाबले छोटे हिस्से को खींचना नहीं चाहते हैं, तब तक आपको अपने बिटमैप को चित्रित करते समय सीमा निर्धारित करने की आवश्यकता नहीं है।

संबंधित मुद्दे

 संबंधित मुद्दे