Java Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP  Java Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python Java Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python Java Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python Java Application Hosting Web Hosting website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, JSP,Python
Java Application Hosting Web Hosting, website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, JSP, Python Java Application Hosting Web Hosting, website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, Python,JSP
Java Application Hosting Web Hosting Sign-Up Java Application Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting  Java Application Hosting Resellers web hosting, website hosting, web site hosting Java Application Hosting EZ Site Control Panel for web hosting,website hosting, web site hosting
Java Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, Python,JSP,  Fundraising
Java Application Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting
WWW.

Call Us Toll-Free
(877) 256-0328

Outside USA
1 - (201) 505-0430

Java Application Hosting Welcome Java Application Hosting Web Hosting Plans Overview , Fund Raising, Fundraising, web hosting, website hosting, web site hosting Java Application Hosting Fund Raising, Fundraising, web hosting Java Application Hosting Resellers, web Hosting Java Application Hosting Web Design, web Hosting Java Application Hosting Extra Services,  web Hosting Java Application Hosting Traffic Booster, web hosting Java Application Hosting Traffic Booster, web hosting Java Application Hosting Technical Support,  web Hosting Java Application Hosting webmaster tips,  web Hosting Java Application Hosting 30 Day Money Back, web hosting Java Application Hosting Legal Notices for Web Hosting Java Application Hosting Glossary Computer Terms for web Hosting Java Application Hosting Contact Information - web hosting

Site Map
Java Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, Python, JSP Java Application Hosting Java Application Hosting Java Application Hosting Java Application Hosting Java Application Hosting Creating and Drawing to an Image (The Java™ Tutorials > 2D Graphics > Working with Images)
Trail: 2D Graphics
Lesson: Working with Images
Home Page > 2D Graphics > Working with Images
Creating and Drawing to an Image

We already know how to load an existing image, which was created and stored in your system or in any network location. But, you probably would like also to create an new image as a pixel data buffer.

In this case, you can create a BufferedImage object manually, using three constructors of this class:

  • new BufferedImage(width, height, type) - constructs a BufferedImage of one of the predefined image types.
  • new BufferedImage(width, height, type, colorModel) - constructs a BufferedImage of one of the predefined image types: TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED.
  • new BufferedImage(colorModel, raster, premultiplied, properties) - constructs a new BufferedImage with a specified ColorModel and Raster.

On the other hand, we can use methods of the Component class. These methods can analyze the display resolution for the given Component or GraphicsConfiguration and create an image of an appropriate type.

  • Component.createImage(width, height)
  • GraphicsConfiguration.createCompatibleImage(width, height)
  • GraphicsConfiguration.createCompatibleImage(width, height, transparency)

GraphicsConfiguration returns an object of BufferedImage type, but the Component returns an object of Image type, if you need a BufferedImage object instead then you can perform an instanceof and cast to a BufferedImage in your code.

As was already mentioned in the previous lessons, we can render images not only on screen. An images itself can be considered as a drawing surface.

You can use a createGraphics() method of the BufferedImage class for this purpose:

Graphics2D g2 = off_Image.createGraphics();

Another interesting use of offscreen images is an automatic double buffering. This feature allows to avoid flicker in animated images by drawing an image to a back buffer and then copying that buffer onto the screen instead of drawing directly to the screen.

Java 2D™ also allows access to hardware acceleration for offscreen images, which can provide the better performance of rendering to and copying from these images. You can get the benefit of this functionality by using the following methods of the Image class:

  • The getCapabilities method allows you to determine whether the image is currently accelerated.
  • The setAccelerationPriority method lets you set a hint about how important acceleration is for the image.
  • The getAccelerationPriority method gets a hint about the acceleration importance.
Previous page: Drawing an Image
Next page: Writing/Saving an Image
 
 
 

Add to My Yahoo!

XML icon

Add to Google

 

 

 

 

 

 

 

 

 

 

 

JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP at JSP.aldenWEBhosting.com Servlets at servlets.aldenWEBhosting.com Tomcat at Tomcat.aldenWEBhosting.com mysql at mysql.aldenWEBhosting.com Java at Java.aldenWEBhosting.com Web Hosts Portal Web Links Web Links Web Hosting JSP Solutions Web Links JSP Solutions Web Hosting Servlets Solutions Web Links Servlets Solutions Web Hosting Web Links Web Links . . .
.
.
. .
.
. .
. . . . . . . . . . . jsp hosting servlets hosting web hosting web sites designed cheap web hosting web site hosting myspace web hosting