Is it possible to create an image from part of a png image?

i have an image and i want to create 4 indivdual image from it in which they could be combined to reform the image that i have
[134 byte] By [lawrencechia_83] at [2007-9-27 20:12:42]
# 1

Its actually quite easy, first you create a new blank image the size of the section you need, then you draw the larger image onto the new image so that the section you want starts at the top left corner of the new image. I use the code below, which works fine.

Image image = Image.createImage("/myimage.png");

int width = [whatever the width of the new image is];

int height = [whatever the height of the new image is];

int x = [x position of where your image section starts];

int y = [y position of where your image section starts];

//Creates a new Blank Image where we will draw our

//section on to

Image imageSection = Image.createImage(width, height);

Graphics g = imageSection.getGraphics();

//set the clip

g.setClip(0,0, width, height);

//Draws our larger image onto our new image

g.drawImage(image, -x, -y, g.TOP|g.LEFT);

brianmflynn at 2007-7-7 0:21:11 > top of Java-index,Java Mobility Forums,Java ME Technologies...