private int processByteOfData(int rgbs[], int repeat, int x, int y,
            int width, int height, DataBuffer db, BufferedImage bi)
            throws ImageReadException
    {
        //                int rbg
        int pixels_written = 0;
        for (int i = 0; i < repeat; i++)
        {

            if ((x >= 0) && (x < width) && (y >= 0) && (y < height))
            {
                //                    int rgb = 0xff000000;
                //                    rgb = getNextRGB();
                int rgb = rgbs[i % rgbs.length];
                //                                bi.setRGB(x, y, rgb);
                db.setElem(y * bhi.width + x, rgb);
                //                                bi.setRGB(x, y, 0xff00ff00);
            }
            else
            {
                System.out.println("skipping bad pixel (" + x + "," + y + ")");
            }

            x++;
            pixels_written++;
        }

        return pixels_written;
    }