I have an image consisting of lot of different frames. There are a lot of transparent pixels in the frames. I have to split the image into individual frames and iterate over the pixel data in an input image/buffer and copy out rectangular regions containing non-transparent pixel data into individual sub images/buffers. So far i've been able to split the image but haven't been able to do further.

void splitImage(string inputFileName, int frameWidth, int frameHeight);
        int rows = 3 ;
        int cols = 4;
        int frames = rows * cols;
        frameWidth = fullImageWidth / cols; //determines the individual frame width
        frameheight = fullImageHeight / rows; //determines the individual frame height
        int count = 0;
        BufferedImage imgs[] = new BufferedImage[frames]; //Image array to hold individual frames
        for(int x=0; x < rows; x++)
            for(int y=0; y < cols; y++)
                //Initialize the image array with idividual frames
                imgs[count]= new BufferedImage(frameWidth, frameHeight, imageFileName.getType());

            //draws the individual frame
            Graphics2D frame = imgs[count].createGraphics();
            frame.drawImage(imageFileName, 0, 0, frameWidth, frameHeight, frameWidth * y,
                frameHeight * x, frameWidth * y + frameWidth, frameHeight * x + frameHeight, null);


Please help.

4 Years
Discussion Span
Last Post by JamesCherrill

You need to scan the pixels in each frame by getting their ARGB values and testing for A (alpha) <255 to identily partially transparent pixels, or A==0 for fully transparent pixels.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.