private void read24Bit(byte[] bdata) {
	// Padding bytes at the end of each scanline
	int padding = 0;

	// width * bitsPerPixel should be divisible by 32
	int bitsPerScanline = width * 24;
	if ( bitsPerScanline%32 != 0) {
	    padding = (bitsPerScanline/32 + 1)*32 - bitsPerScanline;
	    padding = (int)Math.ceil(padding/8.0);
	}

	int imSize = (int)imageSize;
	if (imSize == 0) {
	    imSize = (int)(bitmapFileSize - bitmapOffset);
	}

	// Read till we have the whole image
	byte values[] = new byte[imSize];
	try {
	    int bytesRead = 0;
	    while (bytesRead < imSize) {
		bytesRead += inputStream.read(values, bytesRead,
					      imSize - bytesRead);
	    }
	} catch (IOException ioe) {
	    // throw new RuntimeException(JaiI18N.getString("BMPImageDecoder6"));
            String message = JaiI18N.getString("BMPImageDecoder4");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, ioe),
                                   this, false);
//	    throw new RuntimeException(ioe.getMessage());
	}

	int l=0, count;

	if (isBottomUp) {
	    int max = width*height*3-1;

	    count = -padding;
	    for (int i=0; i<height; i++) {
		l = max - (i+1)*width*3 + 1;
		count += padding;
		for (int j=0; j<width; j++) {
		    bdata[l++] = values[count++];
		    bdata[l++] = values[count++];
		    bdata[l++] = values[count++];
		}
	    }
	} else {
	    count = -padding;
	    for (int i=0; i<height; i++) {
		count += padding;
		for (int j=0; j<width; j++) {
		    bdata[l++] = values[count++];
		    bdata[l++] = values[count++];
		    bdata[l++] = values[count++];
		}
	    }
	}
    }