- الطول: img.getWidth () < / span >< / li>
- الارتفاع: نمط image.getHeight()
- وحدات البكسل والألوان: < span style = "عائلة الخط:" ساعي جديد" , " ساعي" ، حافلة صغيرة؛" >BufferedImage.TYPE_INT_ARGB< / span >.< / li>< / ul >
التحويل بسيط للغاية لأن BufferedImage يرث من السوبر Image class< / a>.< / div>
< / div>BufferedImage العام الثابت toBufferedImage (Image img)
TYPE_INT_ARGB صورة بنوع RGB (RGB) 8 بت ويدعم معلمة عرض ألفا والشفافية < / i> من الفئة alphaComposite< / a>.
{
// إذا كانت الصورة من النوع BufferedImage
// فإننا نلقى
// لأن الصورة التي تم تمريرها من النوع BufferedImage
if (مثيل img من BufferedImage) < br / > {
إرجاع (BufferedImage) img ؛
}
// إنشاء BufferedImage
BufferedImage bufimage = BufferedImage جديد (img.getWidth (null) ،
img.getheight (null) ، BufferedImage.TYPE_INT_ARGB) ؛
عودة bufimage ؛ يمثل
}
المراجع:
http://stackoverflow.com/questions/221830/set-bufferedimage-alpha-mask-in-java< / a>< / div>
Java
Commentaires (0)
Laisser un commentaire
Connectez-vous pour commenter
Rejoignez la discussion et partagez vos connaissances avec la communauté
Chargement des commentaires...