*            the height of the new ImageData
	 * @return a scaled copy of the image
	 */
	public ImageData scaledTo(int width, int height) {
		/* Create a destination image with no data */
		final boolean flipX = (width < 0);
		if (flipX)
			width = -width;
		final boolean flipY = (height < 0);
		if (flipY)
			height = -height;

		ImageData dest = new ImageData(width, height, depth, palette,
				scanlinePad, null, 0, null, null, -1, transparentPixel, type,
				x, y, disposalMethod, delayTime);

		/* Scale the image contents */
		if (palette.isDirect)
			blit(BLIT_SRC, this.data, this.depth, this.bytesPerLine,
					this.getByteOrder(), 0, 0, this.width, this.height, 0, 0,
					0, ALPHA_OPAQUE, null, 0, 0, 0, dest.data, dest.depth,
					dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width,
					dest.height, 0, 0, 0, flipX, flipY);
		else
			blit(BLIT_SRC, this.data, this.depth, this.bytesPerLine,
					this.getByteOrder(), 0, 0, this.width, this.height, null,
					null, null, ALPHA_OPAQUE, null, 0, 0, 0, dest.data,
					dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0,
					dest.width, dest.height, null, null, null, flipX, flipY);

		/* Scale the image mask or alpha */
		if (maskData != null) {
			dest.maskPad = this.maskPad;
			int destBpl = (dest.width + 7) / 8;
			destBpl = (destBpl + (dest.maskPad - 1)) / dest.maskPad
					* dest.maskPad;
			dest.maskData = new byte[destBpl * dest.height];
			int srcBpl = (this.width + 7) / 8;
			srcBpl = (srcBpl + (this.maskPad - 1)) / this.maskPad
					* this.maskPad;
			blit(BLIT_SRC, this.maskData, 1, srcBpl, MSB_FIRST, 0, 0,
					this.width, this.height, null, null, null, ALPHA_OPAQUE,
					null, 0, 0, 0, dest.maskData, 1, destBpl, MSB_FIRST, 0, 0,
					dest.width, dest.height, null, null, null, flipX, flipY);
		} else if (alpha != -1) {
			dest.alpha = this.alpha;
		} else if (alphaData != null) {
			dest.alphaData = new byte[dest.width * dest.height];
			blit(BLIT_SRC, this.alphaData, 8, this.width, MSB_FIRST, 0, 0,
					this.width, this.height, null, null, null, ALPHA_OPAQUE,
					null, 0, 0, 0, dest.alphaData, 8, dest.width, MSB_FIRST, 0,
					0, dest.width, dest.height, null, null, null, flipX, flipY);
		}
		return dest;
	}