} else if (myId.equals("toolbar.fit")) {
imageCanvas.fitCanvas();
return;
} else if (myId.equals("toolbar.rotate")) {
/* rotate image anti-clockwise */
final ImageData src = imageCanvas.getImageData();
if (src == null) {
return;
}
final PaletteData srcPal = src.palette;
PaletteData destPal;
ImageData dest;
/* construct a new ImageData */
if (srcPal.isDirect) {
destPal = new PaletteData(srcPal.redMask, srcPal.greenMask,
srcPal.blueMask);
} else {
destPal = new PaletteData(srcPal.getRGBs());
}
dest = new ImageData(src.height, src.width, src.depth, destPal);
/* rotate by rearranging the pixels */
for (int i = 0; i < src.width; i++) {
for (int j = 0; j < src.height; j++) {
final int pixel = src.getPixel(i, j);
dest.setPixel(j, src.width - 1 - i, pixel);
}
}
imageCanvas.setImageData(dest);
return;
} else if (myId.equals("toolbar.original")) {