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);

            frame.dispose();
            count++;
        }
    };

Please help.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.