import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.skin.EmulatorSkinState;
}
/* custom window shape */
- SkinUtil.trimShell(shell, currentState.getCurrentImage());
+ trimPatchedShell(shell, currentState.getCurrentImage());
/* set window size */
if (currentState.getCurrentImage() != null) {
return lcdBounds;
}
+ public static void trimPatchedShell(Shell shell, Image image) {
+ if (null == image) {
+ return;
+ }
+ ImageData imageData = image.getImageData();
+
+ int width = imageData.width;
+ int height = imageData.height;
+
+ Region region = new Region();
+ region.add(new Rectangle(0, 0, width, height));
+
+ for (int i = 0; i < width; i++) {
+ for (int j = 0; j < height; j++) {
+ int colorPixel = imageData.getPixel(i, j);
+ if (colorPixel == 0xFF00FF /* magenta */) {
+ region.subtract(i, j, 1, 1);
+ }
+ }
+ }
+
+ shell.setRegion(region);
+ }
+
public void addGeneralPurposeListener(final Shell shell) {
shellPaintListener = new PaintListener() {
@Override
import java.util.logging.Logger;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
}
public Image getPatchedImage(int centerPatchWidth, int centerPatchHeight) {
+ int patchedImageWidth = (patchWidth * 2) + centerPatchWidth;
+ int patchedImageHeight = (patchHeight * 2) + centerPatchHeight;
+
Image patchedImage = new Image(display,
- (patchWidth * 2) + centerPatchWidth,
- (patchHeight * 2) + centerPatchHeight);
+ patchedImageWidth, patchedImageHeight);
- // TODO: transparency
+ // TODO: copy alphaData
GC gc = new GC(patchedImage);
+ gc.setBackground(display.getSystemColor(SWT.COLOR_MAGENTA));
+ gc.fillRectangle(0, 0, patchedImageWidth, patchedImageHeight);
/* top side */
gc.drawImage(imageLT, 0, 0);
/* middle side */
gc.drawImage(imageL, 0, 0, imageL.getImageData().width, imageL.getImageData().height,
0, patchHeight, patchWidth, centerPatchHeight);
+ gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
+ gc.fillRectangle(patchWidth, patchHeight, centerPatchWidth, centerPatchHeight); /* center */
gc.drawImage(imageR, 0, 0, imageR.getImageData().width, imageR.getImageData().height,
patchWidth + centerPatchWidth, patchHeight, patchWidth, centerPatchHeight);