* @param pad number of bytes to pad the scanline with (1=byte, 2=short, 4=int, ...)
*/
public static byte[] getBytes(RenderedImage image, Color bkg, String code, int pad) {
if (pad < 1) pad = 1;
Raster raster = image.getData();
int width = image.getWidth();
int height = image.getHeight();
boolean preMultiply = (code.charAt(0) == '*');
if (preMultiply) code = code.substring(1);
int pixelSize = code.length();
int size = width*height*pixelSize;
size += (width % pad)*height;
int index = 0;
byte[] bytes = new byte[size];
ColorModel colorModel = image.getColorModel();
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
int argb = colorModel.getRGB(raster.getDataElements(x, y, (Object)null));
int a = ((argb >> 24) & 0xFF);
int r = ((argb >> 16) & 0xFF);
int g = ((argb >> 8) & 0xFF);
int b = ((argb >> 0) & 0xFF);