From: GiWoong Kim Date: Wed, 4 Dec 2013 06:15:48 +0000 (+0900) Subject: screenshot: code refactoring X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~561 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a60cd551200978a785b4c104a4a202f28fbeee7;p=sdk%2Femulator%2Fqemu.git screenshot: code refactoring 1. restructuring 2. delete unnecessary code 3. fix indenting Change-Id: Ia50fc0454a1a205f7b9a7ae671337303fd2dd0f1 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java index 3bc23c11c3..2042e3a0fe 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java @@ -52,11 +52,6 @@ public class EmulatorFingers { private static final int FINGER_POINT_SIZE = 32; private static final int FINGER_POINT_ALPHA = 0x7E; - private static final int RED_MASK = 0x0000FF00; - private static final int GREEN_MASK = 0x00FF0000; - private static final int BLUE_MASK = 0xFF000000; - private static final int COLOR_DEPTH = 32; - private Logger logger = SkinLogger.getSkinLogger(EmulatorFingers.class).getLogger(); @@ -77,12 +72,12 @@ public class EmulatorFingers { /** * Constructor */ - EmulatorFingers(int maximum, - EmulatorSkinState currentState, SocketCommunicator communicator) { + EmulatorFingers(int maximum, EmulatorSkinState currentState, + SocketCommunicator communicator, PaletteData palette) { this.currentState = currentState; this.communicator = communicator; - initMultiTouchState(maximum); + initMultiTouchState(maximum, palette); } static class FingerPoint { @@ -138,7 +133,7 @@ public class EmulatorFingers { return null; } - private void initMultiTouchState(int maximum) { + private void initMultiTouchState(int maximum, PaletteData palette) { multiTouchEnable = 0; int fingerCntMax = maximum; @@ -160,10 +155,9 @@ public class EmulatorFingers { Color pointOutlineColor = new Color(Display.getCurrent(), 0xDD, 0xDD, 0xDD); Color pointColor = new Color(Display.getCurrent(), 0x0F, 0x0F, 0x0F); - PaletteData palette = new PaletteData(RED_MASK, GREEN_MASK, BLUE_MASK); ImageData imageData = new ImageData( - fingerPointSize + 4, fingerPointSize + 4, COLOR_DEPTH, palette); + fingerPointSize + 4, fingerPointSize + 4, 32, palette); imageData.transparentPixel = 0; this.fingerPointImage = new Image(Display.getCurrent(), imageData); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java index 4394193799..05fc5ff568 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java @@ -33,6 +33,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.PaletteData; import org.tizen.emulator.skin.comm.sock.data.StartData; import org.tizen.emulator.skin.config.EmulatorConfig; import org.tizen.emulator.skin.dbi.OptionType; @@ -45,15 +46,22 @@ import org.tizen.emulator.skin.util.SkinUtil; import org.tizen.emulator.skin.util.SwtUtil; public class EmulatorSdlSkin extends EmulatorSkin { + public static final int DISPLAY_COLOR_DEPTH = 32; + private Logger logger = SkinLogger.getSkinLogger( EmulatorSdlSkin.class).getLogger(); + private PaletteData palette; + /** * Constructor */ public EmulatorSdlSkin(EmulatorConfig config, SkinInformation skinInfo, boolean isOnTop) { super(config, skinInfo, SWT.EMBEDDED, isOnTop); + + /* BGRA */ + this.palette = new PaletteData(0x0000FF00, 0x00FF0000, 0xFF000000); } @Override @@ -149,11 +157,11 @@ public class EmulatorSdlSkin extends EmulatorSkin { return; } + screenShotDialog = new SdlScreenShotWindow(this, config, + palette, imageRegistry.getIcon(IconName.SCREENSHOT)); + try { - screenShotDialog = new SdlScreenShotWindow(shell, this, config, - imageRegistry.getIcon(IconName.SCREENSHOT)); screenShotDialog.open(); - } catch (ScreenShotException ex) { screenShotDialog = null; logger.log(Level.SEVERE, ex.getMessage(), ex); @@ -169,5 +177,4 @@ public class EmulatorSdlSkin extends EmulatorSkin { SWT.ICON_WARNING, config); } } - } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java index 11682065e1..65a9a7197c 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java @@ -61,10 +61,7 @@ import org.tizen.emulator.skin.util.SkinUtil; import org.tizen.emulator.skin.util.SwtUtil; public class EmulatorShmSkin extends EmulatorSkin { - public static final int RED_MASK = 0x00FF0000; - public static final int GREEN_MASK = 0x0000FF00; - public static final int BLUE_MASK = 0x000000FF; - public static final int COLOR_DEPTH = 24; /* no need to Alpha channel */ + public static final int DISPLAY_COLOR_DEPTH = 24; /* no need to Alpha channel */ /* touch values */ protected static int pressingX = -1, pressingY = -1; @@ -97,7 +94,7 @@ public class EmulatorShmSkin extends EmulatorSkin { public native int shmdt(); public native int getPixels(int[] array); - private PaletteData paletteData; + private PaletteData palette; private PollFBThread pollThread; private Image imageGuide; @@ -120,7 +117,10 @@ public class EmulatorShmSkin extends EmulatorSkin { private Runnable runnable; private int intervalWait; - public PollFBThread(int widthFB, int heightFB) { + /** + * Constructor + */ + public PollFBThread(PaletteData paletteDisplay, int widthFB, int heightFB) { this.display = Display.getDefault(); this.widthFB = widthFB; this.heightFB = heightFB; @@ -128,7 +128,7 @@ public class EmulatorShmSkin extends EmulatorSkin { this.arrayFramebuffer = new int[sizeFramebuffer]; this.dataFramebuffer = - new ImageData(widthFB, heightFB, COLOR_DEPTH, paletteData); + new ImageData(widthFB, heightFB, DISPLAY_COLOR_DEPTH, paletteDisplay); this.imageFramebuffer = new Image(Display.getDefault(), dataFramebuffer); @@ -217,13 +217,12 @@ public class EmulatorShmSkin extends EmulatorSkin { SkinInformation skinInfo, boolean isOnTop) { super(config, skinInfo, SWT.NONE, isOnTop); - this.paletteData = new PaletteData(RED_MASK, GREEN_MASK, BLUE_MASK); + /* ARGB */ + this.palette = new PaletteData(0x00FF0000, 0x0000FF00, 0x000000FF); /* get MaxTouchPoint from startup argument */ this.maxTouchPoint = config.getArgInt( ArgsConstants.INPUT_TOUCH_MAXPOINT); - - this.imageGuide = null; } @Override @@ -241,7 +240,9 @@ public class EmulatorShmSkin extends EmulatorSkin { public StartData initSkin() { initLayout(); - finger = new EmulatorFingers(maxTouchPoint, currentState, communicator); + finger = new EmulatorFingers(maxTouchPoint, + currentState, communicator, palette); + if (SwtUtil.isMacPlatform() == true) { multiTouchKey = SWT.COMMAND; } else { @@ -302,7 +303,7 @@ public class EmulatorShmSkin extends EmulatorSkin { } /* display updater thread */ - pollThread = new PollFBThread( + pollThread = new PollFBThread(palette, currentState.getCurrentResolutionWidth(), currentState.getCurrentResolutionHeight()); @@ -628,11 +629,11 @@ public class EmulatorShmSkin extends EmulatorSkin { return; } + screenShotDialog = new ShmScreenShotWindow(this, config, + palette, imageRegistry.getIcon(IconName.SCREENSHOT)); + try { - screenShotDialog = new ShmScreenShotWindow(shell, this, config, - imageRegistry.getIcon(IconName.SCREENSHOT)); screenShotDialog.open(); - } catch (ScreenShotException ex) { screenShotDialog = null; logger.log(Level.SEVERE, ex.getMessage(), ex); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java index 4ca8b43f7e..3c461987fe 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java @@ -1,5 +1,5 @@ /** - * Capture a screenshot of the Emulator framebuffer + * Screenshot Window * * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * @@ -53,11 +53,12 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.ImageLoader; import org.eclipse.swt.graphics.PaletteData; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.FileDialog; @@ -69,7 +70,6 @@ import org.eclipse.swt.widgets.ToolItem; import org.tizen.emulator.skin.EmulatorSkin; import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo; import org.tizen.emulator.skin.config.EmulatorConfig; -import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants; import org.tizen.emulator.skin.exception.ScreenShotException; import org.tizen.emulator.skin.image.ImageRegistry; import org.tizen.emulator.skin.image.ImageRegistry.IconName; @@ -80,50 +80,51 @@ import org.tizen.emulator.skin.util.StringUtil; import org.tizen.emulator.skin.util.SwtUtil; public class ScreenShotDialog { - public final static String DEFAULT_FILE_EXTENSION = "png"; - public static final int CANVAS_MARGIN = 30; - public static final int TOOLITEM_COOLTIME = 200; + private final static String DETAIL_SCREENSHOT_WINDOW_TITLE = "Screen Shot"; + + private final static String DEFAULT_FILE_EXTENSION = "png"; + private static final int CANVAS_MARGIN = 30; + private static final int TOOLITEM_COOLTIME = 200; + private static final double MIN_SCALE_FACTOR = 12.5; + private static final double MAX_SCALE_FACTOR = 800; private static Logger logger = SkinLogger.getSkinLogger(ScreenShotDialog.class).getLogger(); - protected PaletteData paletteData_ARGB; - protected PaletteData paletteData_BGRA; - protected PaletteData paletteData_RGBA; - protected Image image; - protected Canvas imageCanvas; + protected EmulatorSkin skin; + protected EmulatorConfig config; + private Shell shell; private ScrolledComposite scrollComposite; - private Label label; + protected Canvas canvasFrame; + protected Image imageFrame; + private Composite statusComposite; + private Label labelResolution; + private Label labelScale; - protected EmulatorSkin emulatorSkin; - protected EmulatorConfig config; - - private RotationInfo currentRotation; - private boolean reserveImage; private ToolItem refreshItem; private ToolItem copyItem; - private ToolItem increaseScaleItem; - private ToolItem decreaseScaleItem; + private ToolItem zoomInItem; + private ToolItem zoomOutItem; private double scaleLevel; /** * @brief constructor * @param Image icon : screenshot window icon resource */ - public ScreenShotDialog(Shell parent, - final EmulatorSkin emulatorSkin, EmulatorConfig config, - Image icon) throws ScreenShotException { - this.emulatorSkin = emulatorSkin; + public ScreenShotDialog(final EmulatorSkin skin, + EmulatorConfig config, Image icon) { + this.skin = skin; this.config = config; - this.scaleLevel = 100d; + this.scaleLevel = 100; if (SwtUtil.isMacPlatform() == false) { - shell = new Shell(parent, SWT.SHELL_TRIM); + shell = new Shell(skin.getShell(), SWT.SHELL_TRIM); } else { - shell = new Shell(parent.getDisplay(), SWT.SHELL_TRIM); + shell = new Shell(skin.getShell().getDisplay(), SWT.SHELL_TRIM); } - shell.setText("Screen Shot - " + SkinUtil.makeEmulatorName(config)); + shell.setText(DETAIL_SCREENSHOT_WINDOW_TITLE + + " - " + SkinUtil.makeEmulatorName(config)); /* To prevent the icon switching on Mac */ if (SwtUtil.isMacPlatform() == false) { @@ -137,15 +138,13 @@ public class ScreenShotDialog { public void handleEvent(Event event) { logger.info("ScreenShot Window is closed"); - if (null != image) { - if (!reserveImage) { - image.dispose(); - } + if (null != imageFrame) { + imageFrame.dispose(); } - emulatorSkin.screenShotDialog = null; + skin.screenShotDialog = null; } - } ); + }); GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 0; @@ -154,64 +153,45 @@ public class ScreenShotDialog { gridLayout.verticalSpacing = 0; shell.setLayout(gridLayout); - makeMenuBar(shell); + /* tool bar */ + createToolBar(shell); - scrollComposite = new ScrolledComposite( shell, SWT.V_SCROLL | SWT.H_SCROLL ); - GridData gridData = new GridData( SWT.FILL, SWT.FILL, true, true ); - scrollComposite.setLayoutData( gridData ); + /* screenshot canvas */ + scrollComposite = new ScrolledComposite(shell, SWT.V_SCROLL | SWT.H_SCROLL); + GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); + scrollComposite.setLayoutData(gridData); - scrollComposite.setExpandHorizontal( true ); - scrollComposite.setExpandVertical( true ); + scrollComposite.setExpandHorizontal(true); + scrollComposite.setExpandVertical(true); - currentRotation = getCurrentRotation(); + canvasFrame = new Canvas(scrollComposite, SWT.NONE); + canvasFrame.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); - imageCanvas = new Canvas( scrollComposite, SWT.NONE ); - imageCanvas.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_DARK_GRAY ) ); - imageCanvas.addPaintListener( new PaintListener() { + canvasFrame.addPaintListener(new PaintListener() { @Override - public void paintControl( PaintEvent e ) { + public void paintControl(PaintEvent e) { + logger.fine("draw frame"); - logger.fine( "paint image." ); + if (null != imageFrame && !imageFrame.isDisposed()) { + e.gc.setInterpolation(SWT.NONE); - if ( null != image && !image.isDisposed() ) { - //e.gc.drawImage( image, CANVAS_MARGIN, CANVAS_MARGIN ); - Rectangle r = image.getBounds(); + Rectangle r = imageFrame.getBounds(); //logger.info("r.width: " +r.width +", r.height " + r.height); - - e.gc.drawImage(image, 0, 0, r.width, r.height, + e.gc.drawImage(imageFrame, 0, 0, r.width, r.height, CANVAS_MARGIN, CANVAS_MARGIN, (int)(r.width * scaleLevel / 100), (int)(r.height * scaleLevel / 100)); } } - } ); - - paletteData_ARGB = new PaletteData(0x00FF0000, 0x0000FF00, 0x000000FF); - - /* for Endian */ - paletteData_BGRA = new PaletteData(0x0000FF00, 0x00FF0000, 0xFF000000); - /* for clipboard on Windows */ - paletteData_RGBA = new PaletteData(0xFF000000, 0x00FF0000, 0x0000FF00); + }); - scrollComposite.setContent(imageCanvas); + scrollComposite.setContent(canvasFrame); - try { - clickShutter(); - } catch ( ScreenShotException e ) { - if ( !shell.isDisposed() ) { - shell.close(); - } - throw e; - } + /* status bar */ + createStatusBar(shell); shell.pack(); - label = new Label(shell, SWT.NORMAL); - label.setText(" Resolution : " + - config.getArgInt(ArgsConstants.RESOLUTION_WIDTH) + "x" + - config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT) + " " + - scaleLevel + "%"); - // imageCanvas.addMouseMoveListener(new MouseMoveListener() { // public void mouseMove(MouseEvent e) { // Rectangle rectangle = imageCanvas.getBounds(); @@ -234,12 +214,12 @@ public class ScreenShotDialog { // } // }); - Rectangle monitorBounds = Display.getDefault().getBounds(); + final Rectangle monitorBounds = Display.getDefault().getBounds(); logger.info("host monitor display bounds : " + monitorBounds); - Rectangle emulatorBounds = parent.getBounds(); + final Rectangle emulatorBounds = skin.getShell().getBounds(); logger.info("current Emulator window bounds : " + emulatorBounds); Rectangle dialogBounds = shell.getBounds(); - logger.info("current ScreenShot Dialog bounds : " + dialogBounds); + logger.info("current ScreenShot window bounds : " + dialogBounds); /* size correction */ shell.setSize(emulatorBounds.width, emulatorBounds.height); @@ -259,35 +239,21 @@ public class ScreenShotDialog { } shell.setLocation(x, y); - dialogBounds = shell.getBounds(); - logger.info("current ScreenShot Dialog bounds : " + dialogBounds); + logger.info("ScreenShot window bounds : " + shell.getBounds()); } -// private void drawRotatedImage( GC gc, int width, int height ) { -// -// Transform transform = new Transform( shell.getDisplay() ); -// -// float angle = currentRotation.angle(); -// transform.rotate( angle ); -// -// if ( RotationInfo.LANDSCAPE.equals( currentRotation ) ) { -// transform.translate( -width - ( 2 * CANVAS_MARGIN ), 0 ); -// } else if ( RotationInfo.REVERSE_PORTRAIT.equals( currentRotation ) ) { -// transform.translate( -width - ( 2 * CANVAS_MARGIN ), -height - ( 2 * CANVAS_MARGIN ) ); -// } else if ( RotationInfo.REVERSE_LANDSCAPE.equals( currentRotation ) ) { -// transform.translate( 0, -height - ( 2 * CANVAS_MARGIN ) ); -// } -// gc.setTransform( transform ); -// -// gc.drawImage( image, CANVAS_MARGIN, CANVAS_MARGIN ); -// -// transform.dispose(); -// -// } - private void clickShutter() throws ScreenShotException { capture(); - arrageImageLayout(); + + /* set as 100% view */ + setScaleLevel(100); + + shell.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + updateWindow(); + } + }); } protected void capture() throws ScreenShotException { @@ -300,63 +266,57 @@ public class ScreenShotDialog { private void setScaleLevel(double level) { scaleLevel = level; + logger.info("set scaling level : " + scaleLevel); } - + private void downScaleLevel() { scaleLevel /= 2; logger.info("down scaling level : " + scaleLevel); } - + private void upScaleLevel() { scaleLevel *= 2; logger.info("up scaling level : " + scaleLevel); } - - private void arrageImageLayout() { - - ImageData imageData = image.getImageData(); - scaleLevel = 100d; - int width = imageData.width + ( 2 * CANVAS_MARGIN ); - int height = imageData.height + ( 2 * CANVAS_MARGIN ); - logger.info("arrageImageLayout width:" + width + ", height: "+ height); - scrollComposite.setMinSize( width, height ); - - RotationInfo rotation = getCurrentRotation(); - if ( !currentRotation.equals( rotation ) ) { // reserve changed shell size by user - shell.pack(); - } - currentRotation = rotation; + private void updateWindow() { + logger.info("update"); - } - - private void scaledImageLayout() { - - ImageData imageData = image.getImageData(); - - int width = imageData.width + ( 2 * CANVAS_MARGIN ); - int height = imageData.height + ( 2 * CANVAS_MARGIN ); - logger.info("arrageImageLayout2 width:" + width + ", height: "+ height); - int reWidth = (int)(width * scaleLevel * 1/100); - int reHeight = (int)(height * scaleLevel * 1/100); - logger.info("arrageImageLayout2 Rewidth:" + reWidth + ", Reheight: "+ reHeight); - scrollComposite.setMinSize( (int)(imageData.width * scaleLevel * 1/100) + ( 2 * CANVAS_MARGIN ), (int)(imageData.height * scaleLevel * 1/100) + ( 2 * CANVAS_MARGIN )); - - RotationInfo rotation = getCurrentRotation(); - if ( !currentRotation.equals( rotation ) ) { // reserve changed shell size by user - shell.pack(); + if (imageFrame != null) { + ImageData imageData = imageFrame.getImageData(); + int width = (int)(imageData.width * scaleLevel / 100) + (2 * CANVAS_MARGIN); + int height = (int)(imageData.height * scaleLevel / 100) + (2 * CANVAS_MARGIN); + logger.info("update composite width : " + width + ", height : " + height); + + scrollComposite.setMinSize(width, height); } - currentRotation = rotation; + /* update tool bar */ + if (getScaleLevel() >= MAX_SCALE_FACTOR) { + zoomInItem.setEnabled(false); + zoomOutItem.setEnabled(true); + } else if (getScaleLevel() <= MIN_SCALE_FACTOR) { + zoomOutItem.setEnabled(false); + zoomInItem.setEnabled(true); + } else { + zoomInItem.setEnabled(true); + zoomOutItem.setEnabled(true); + } - } - + /* update image */ + canvasFrame.redraw(); - protected ImageData rotateImageData( ImageData srcData, RotationInfo rotation ) { + /* update status bar */ + if (labelScale != null) { + labelScale.setText(" " + scaleLevel + "% "); + labelScale.update(); + } + } + protected ImageData rotateImageData(ImageData srcData, RotationInfo rotation) { int direction = SWT.NONE; - switch ( rotation ) { + switch (rotation) { case PORTRAIT: return srcData; case LANDSCAPE: @@ -372,123 +332,126 @@ public class ScreenShotDialog { return srcData; } - ImageData rotatedData = rotateImageData( srcData, direction ); + ImageData rotatedData = rotateImageData(srcData, direction); return rotatedData; - } /* * refrence web page : http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/Rotateandflipanimage.htm */ - private ImageData rotateImageData( ImageData srcData, int direction ) { + private ImageData rotateImageData(ImageData srcData, int direction) { int bytesPerPixel = srcData.bytesPerLine / srcData.width; - int destBytesPerLine = ( direction == SWT.DOWN ) ? srcData.width * bytesPerPixel : srcData.height - * bytesPerPixel; + int destBytesPerLine = (direction == SWT.DOWN) ? + srcData.width * bytesPerPixel : srcData.height * bytesPerPixel; + byte[] newData = new byte[srcData.data.length]; - int width = 0, height = 0; - for ( int srcY = 0; srcY < srcData.height; srcY++ ) { - for ( int srcX = 0; srcX < srcData.width; srcX++ ) { - int destX = 0, destY = 0, destIndex = 0, srcIndex = 0; - switch ( direction ) { - case SWT.LEFT: // left 90 degrees + int srcWidth = 0, srcHeight = 0; + + int destX = 0, destY = 0, destIndex = 0, srcIndex = 0; + for (int srcY = 0; srcY < srcData.height; srcY++) { + for (int srcX = 0; srcX < srcData.width; srcX++) { + switch (direction) { + case SWT.LEFT: /* left 90 degrees */ destX = srcY; destY = srcData.width - srcX - 1; - width = srcData.height; - height = srcData.width; + srcWidth = srcData.height; + srcHeight = srcData.width; break; - case SWT.RIGHT: // right 90 degrees + case SWT.RIGHT: /* right 90 degrees */ destX = srcData.height - srcY - 1; destY = srcX; - width = srcData.height; - height = srcData.width; + srcWidth = srcData.height; + srcHeight = srcData.width; break; - case SWT.DOWN: // 180 degrees + case SWT.DOWN: /* 180 degrees */ destX = srcData.width - srcX - 1; destY = srcData.height - srcY - 1; - width = srcData.width; - height = srcData.height; + srcWidth = srcData.width; + srcHeight = srcData.height; break; } - destIndex = ( destY * destBytesPerLine ) + ( destX * bytesPerPixel ); - srcIndex = ( srcY * srcData.bytesPerLine ) + ( srcX * bytesPerPixel ); - System.arraycopy( srcData.data, srcIndex, newData, destIndex, bytesPerPixel ); + + destIndex = (destY * destBytesPerLine) + (destX * bytesPerPixel); + srcIndex = (srcY * srcData.bytesPerLine) + (srcX * bytesPerPixel); + System.arraycopy(srcData.data, srcIndex, newData, destIndex, bytesPerPixel); } } - // destBytesPerLine is used as scanlinePad to ensure that no padding is - // required - return new ImageData( width, height, srcData.depth, srcData.palette, destBytesPerLine, newData ); + /* destBytesPerLine is used as scanlinePad + * to ensure that no padding is required */ + return new ImageData(srcWidth, srcHeight, + srcData.depth, srcData.palette, destBytesPerLine, newData); } protected RotationInfo getCurrentRotation() { short currentRotationId = - emulatorSkin.getEmulatorSkinState().getCurrentRotationId(); + skin.getEmulatorSkinState().getCurrentRotationId(); RotationInfo rotationInfo = RotationInfo.getValue(currentRotationId); return rotationInfo; } - private void makeMenuBar(final Shell shell) { - ToolBar toolBar = new ToolBar(shell, SWT.HORIZONTAL); + private void createToolBar(final Shell parent) { + ImageRegistry imageRegistry = skin.getImageRegistry(); + + ToolBar toolBar = new ToolBar(parent, SWT.HORIZONTAL | SWT.BORDER); GridData gridData = new GridData( GridData.FILL_HORIZONTAL, GridData.CENTER, true, false); toolBar.setLayoutData(gridData); /* save */ - ToolItem saveItem = new ToolItem( toolBar, SWT.FLAT ); - saveItem.setImage( ImageRegistry.getInstance().getIcon( IconName.SAVE_SCREEN_SHOT ) ); - saveItem.setToolTipText( "Save to file" ); + ToolItem saveItem = new ToolItem(toolBar, SWT.FLAT); + saveItem.setImage(imageRegistry.getIcon(IconName.SAVE_SCREEN_SHOT)); + saveItem.setToolTipText("Save to file"); - saveItem.addSelectionListener( new SelectionAdapter() { + saveItem.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { - - FileDialog fileDialog = new FileDialog( shell, SWT.SAVE ); - fileDialog.setText( "Save Image" ); + public void widgetSelected(SelectionEvent e) { + FileDialog fileDialog = new FileDialog(parent, SWT.SAVE); + fileDialog.setText("Save Image"); String[] filter = { "*.png;*.PNG;*.jpg;*.JPG;*.jpeg;*.JPEG;*.bmp;*.BMP" }; - fileDialog.setFilterExtensions( filter ); + fileDialog.setFilterExtensions(filter); String[] filterName = { "Image files (*.png *.jpg *.jpeg *.bmp)" }; - fileDialog.setFilterNames( filterName ); + fileDialog.setFilterNames(filterName); - String vmName = SkinUtil.getVmName( config ); - SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd-hhmmss" ); - String dateString = formatter.format( new Date( System.currentTimeMillis() ) ); + String vmName = SkinUtil.getVmName(config); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-hhmmss"); + String dateString = formatter.format(new Date(System.currentTimeMillis())); - fileDialog.setFileName( vmName + "-" + dateString + "." + DEFAULT_FILE_EXTENSION ); + fileDialog.setFileName(vmName + "-" + dateString + "." + DEFAULT_FILE_EXTENSION); - String userHome = System.getProperty( "user.home" ); - if ( !StringUtil.isEmpty( userHome ) ) { - fileDialog.setFilterPath( userHome ); + String userHome = System.getProperty("user.home"); + if (!StringUtil.isEmpty(userHome)) { + fileDialog.setFilterPath(userHome); } else { - logger.warning( "Cannot find user home path int java System properties." ); + logger.warning("Cannot find user home path in java System properties."); } fileDialog.setOverwrite(true); String filePath = fileDialog.open(); - saveFile( filePath, fileDialog ); - + saveFile(filePath, fileDialog); } - - } ); + }); /* copy to clipboard */ - copyItem = new ToolItem( toolBar, SWT.FLAT ); - copyItem.setImage( ImageRegistry.getInstance().getIcon( IconName.COPY_SCREEN_SHOT ) ); - copyItem.setToolTipText( "Copy to clipboard" ); + copyItem = new ToolItem(toolBar, SWT.FLAT); + copyItem.setImage(imageRegistry.getIcon(IconName.COPY_SCREEN_SHOT)); + copyItem.setToolTipText("Copy to clipboard"); - copyItem.addSelectionListener( new SelectionAdapter() { + copyItem.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { - if (null == image || image.isDisposed()) { - SkinUtil.openMessage(shell, null, + public void widgetSelected(SelectionEvent e) { + if (null == imageFrame || imageFrame.isDisposed()) { + SkinUtil.openMessage(parent, null, "Fail to copy to clipboard.", SWT.ICON_ERROR, config); return; } copyItem.setEnabled(false); - shell.getDisplay().asyncExec(new Runnable() { + parent.getDisplay().asyncExec(new Runnable() { + @Override public void run() { try { Thread.sleep(TOOLITEM_COOLTIME); @@ -500,51 +463,43 @@ public class ScreenShotDialog { }); ImageLoader loader = new ImageLoader(); - ImageData data = null; + ImageData frameData = imageFrame.getImageData(); if (SwtUtil.isWindowsPlatform()) { - /* change RGB mask */ - ImageData imageData = image.getImageData(); - data = new ImageData(imageData.width, imageData.height, - imageData.depth, paletteData_RGBA, - imageData.bytesPerLine, imageData.data); - } else { - data = image.getImageData(); + /* convert to RGBA */ + frameData.palette = + new PaletteData(0xFF000000, 0x00FF0000, 0x0000FF00); } - loader.data = new ImageData[] { data }; + loader.data = new ImageData[] { frameData }; ByteArrayOutputStream bao = new ByteArrayOutputStream(); - loader.save( bao, SWT.IMAGE_PNG ); + loader.save(bao, SWT.IMAGE_PNG); - ImageData imageData = new ImageData( new ByteArrayInputStream( bao.toByteArray() ) ); - Object[] imageObject = new Object[] { imageData }; + ImageData pngData = new ImageData( + new ByteArrayInputStream(bao.toByteArray())); + Object[] imageObject = new Object[] { pngData }; Transfer[] transfer = new Transfer[] { ImageTransfer.getInstance() }; - - Clipboard clipboard = new Clipboard( shell.getDisplay() ); - clipboard.setContents( imageObject, transfer ); - + Clipboard clipboard = new Clipboard(parent.getDisplay()); + clipboard.setContents(imageObject, transfer); } + }); - } ); + new ToolItem(toolBar, SWT.SEPARATOR); /* refresh */ - refreshItem = new ToolItem( toolBar, SWT.FLAT ); - refreshItem.setImage( ImageRegistry.getInstance().getIcon( IconName.REFRESH_SCREEN_SHOT ) ); - refreshItem.setToolTipText( "Refresh image" ); + refreshItem = new ToolItem(toolBar, SWT.FLAT); + refreshItem.setImage(imageRegistry.getIcon(IconName.REFRESH_SCREEN_SHOT)); + refreshItem.setToolTipText("Refresh image"); - refreshItem.addSelectionListener( new SelectionAdapter() { + refreshItem.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { - + public void widgetSelected(SelectionEvent e) { refreshItem.setEnabled(false); - /* set as 100% view */ - setScaleLevel(100d); - label.setText(" Resolution : " + config.getArgInt(ArgsConstants.RESOLUTION_WIDTH) + - "x" + config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT) + " " + scaleLevel + "%"); - label.update(); - shell.getDisplay().asyncExec(new Runnable() { + + parent.getDisplay().asyncExec(new Runnable() { + @Override public void run() { try { Thread.sleep(TOOLITEM_COOLTIME); @@ -555,126 +510,89 @@ public class ScreenShotDialog { } }); - Point dialogSize = shell.getSize(); - try { clickShutter(); } catch (ScreenShotException ex) { logger.log(Level.SEVERE, "Fail to create a screen shot.", ex); - SkinUtil.openMessage(shell, null, + SkinUtil.openMessage(parent, null, "Fail to create a screen shot.", SWT.ERROR, config); } - - /* restoration */ - if (shell.getSize() != dialogSize) { - shell.setSize(dialogSize); - } } + }); - } ); + new ToolItem(toolBar, SWT.SEPARATOR); /* zoom in */ - increaseScaleItem = new ToolItem(toolBar, SWT.FLAT); - increaseScaleItem.setImage(ImageRegistry.getInstance().getIcon(IconName.INCREASE_SCALE)); - increaseScaleItem.setToolTipText("Increase view size"); + zoomInItem = new ToolItem(toolBar, SWT.FLAT); + zoomInItem.setImage(imageRegistry.getIcon(IconName.INCREASE_SCALE)); + zoomInItem.setToolTipText("Zoom in"); - increaseScaleItem.addSelectionListener(new SelectionAdapter() { + zoomInItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - double level = getScaleLevel(); - Point dialogSize = shell.getSize(); - upScaleLevel(); - imageCanvas.redraw(); - scaledImageLayout(); - label.setText(" Resolution : " + config.getArgInt(ArgsConstants.RESOLUTION_WIDTH) + - "x" + config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT) + " " + scaleLevel + "%"); - label.update(); - - if (level >= 400d) { - increaseScaleItem.setEnabled(false); - decreaseScaleItem.setEnabled(true); - } else { - increaseScaleItem.setEnabled(true); - decreaseScaleItem.setEnabled(true); - } - - /* restoration */ - if (shell.getSize() != dialogSize) { - shell.setSize(dialogSize); - } + updateWindow(); } - - } ); + }); /* zoom out */ - decreaseScaleItem = new ToolItem(toolBar, SWT.FLAT); - decreaseScaleItem.setImage(ImageRegistry.getInstance().getIcon(IconName.DECREASE_SCALE)); - decreaseScaleItem.setToolTipText("Decrease view size"); + zoomOutItem = new ToolItem(toolBar, SWT.FLAT); + zoomOutItem.setImage(imageRegistry.getIcon(IconName.DECREASE_SCALE)); + zoomOutItem.setToolTipText("Zoom out"); - decreaseScaleItem.addSelectionListener(new SelectionAdapter() { + zoomOutItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - double level = getScaleLevel(); - Point dialogSize = shell.getSize(); - downScaleLevel(); - imageCanvas.redraw(); - scaledImageLayout(); - label.setText(" Resolution : " + config.getArgInt(ArgsConstants.RESOLUTION_WIDTH) + - "x" + config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT) + " " + scaleLevel + "%"); - label.update(); - - if (level <= 25) { - decreaseScaleItem.setEnabled(false); - increaseScaleItem.setEnabled(true); - } else { - decreaseScaleItem.setEnabled(true); - increaseScaleItem.setEnabled(true); - } - - /* restoration */ - if (shell.getSize() != dialogSize) { - shell.setSize(dialogSize); - } + updateWindow(); } + }); + } - } ); + private void createStatusBar(final Shell parent) { + statusComposite = new Composite(parent, SWT.NONE); + RowLayout row = new RowLayout(SWT.HORIZONTAL); + row.marginLeft = 0; + row.marginTop = row.marginBottom = 0; + statusComposite.setLayout(row); - - } + labelResolution = new Label(statusComposite, SWT.BORDER | SWT.SHADOW_IN); + labelResolution.setText(" Resolution : " + + skin.getEmulatorSkinState().getCurrentResolutionWidth() + "x" + + skin.getEmulatorSkinState().getCurrentResolutionHeight() + " "); - private void saveFile( String fileFullPath, FileDialog fileDialog ) { + labelScale = new Label(statusComposite, SWT.BORDER | SWT.SHADOW_IN); + labelScale.setText(" " + scaleLevel + "% "); + } - if ( null == fileFullPath ) { + private void saveFile(String fileFullPath, FileDialog fileDialog) { + if (null == fileFullPath) { return; } String format = ""; - String[] split = fileFullPath.split( "\\." ); - - if ( 1 < split.length ) { + String[] split = fileFullPath.split("\\."); + if (1 < split.length) { format = split[split.length - 1]; - if ( new File( split[split.length - 2] ).isDirectory() ) { - // There is no file name. - SkinUtil.openMessage( shell, null, "Use correct file name.", SWT.ICON_WARNING, config ); - String path = fileDialog.open(); - saveFile( path, fileDialog ); + if (new File(split[split.length - 2]).isDirectory()) { + /* There is no file name */ + SkinUtil.openMessage(shell, null, + "Use correct file name.", SWT.ICON_WARNING, config); + String path = fileDialog.open(); + saveFile(path, fileDialog); } - } FileOutputStream fos = null; try { - - if ( StringUtil.isEmpty( format ) ) { - if ( fileFullPath.endsWith( "." ) ) { + if (StringUtil.isEmpty(format)) { + if (fileFullPath.endsWith(".")) { fileFullPath += DEFAULT_FILE_EXTENSION; } else { fileFullPath += "." + DEFAULT_FILE_EXTENSION; @@ -682,77 +600,59 @@ public class ScreenShotDialog { } ImageLoader loader = new ImageLoader(); - loader.data = new ImageData[] { image.getImageData() }; - - if ( StringUtil.isEmpty( format ) || format.equalsIgnoreCase( "png" ) ) { - fos = new FileOutputStream( fileFullPath, false ); - loader.save( fos, SWT.IMAGE_PNG ); - } else if ( format.equalsIgnoreCase( "jpg" ) || format.equalsIgnoreCase( "jpeg" ) ) { - fos = new FileOutputStream( fileFullPath, false ); - loader.save( fos, SWT.IMAGE_JPEG ); - } else if ( format.equalsIgnoreCase( "bmp" ) ) { - fos = new FileOutputStream( fileFullPath, false ); - loader.save( fos, SWT.IMAGE_BMP ); + loader.data = new ImageData[] { imageFrame.getImageData() }; + + if (StringUtil.isEmpty(format) || format.equalsIgnoreCase("png")) { + fos = new FileOutputStream(fileFullPath, false); + loader.save(fos, SWT.IMAGE_PNG); + } else if (format.equalsIgnoreCase("jpg") || format.equalsIgnoreCase("jpeg")) { + fos = new FileOutputStream(fileFullPath, false); + loader.save(fos, SWT.IMAGE_JPEG); + } else if (format.equalsIgnoreCase("bmp")) { + fos = new FileOutputStream(fileFullPath, false); + loader.save(fos, SWT.IMAGE_BMP); } else { + SkinUtil.openMessage(shell, null, + "Use the specified image formats. (PNG / JPG / JPEG / BMP)", + SWT.ICON_WARNING, config); - SkinUtil.openMessage( shell, null, - "Use the specified image formats. ( PNG / JPG / JPEG / BMP )", - SWT.ICON_WARNING, config ); String path = fileDialog.open(); - saveFile( path, fileDialog ); - + saveFile(path, fileDialog); } + } catch (FileNotFoundException ex) { + logger.log(Level.WARNING, "Use correct file name.", ex); + SkinUtil.openMessage(shell, null, "Use correct file name.", SWT.ICON_WARNING, config); - } catch ( FileNotFoundException ex ) { - - logger.log( Level.WARNING, "Use correct file name.", ex ); - SkinUtil.openMessage( shell, null, "Use correct file name.", SWT.ICON_WARNING, config ); String path = fileDialog.open(); - saveFile( path, fileDialog ); + saveFile(path, fileDialog); + } catch (Exception ex) { + logger.log(Level.SEVERE, "Fail to save this image file.", ex); + SkinUtil.openMessage(shell, null, "Fail to save this image file.", SWT.ERROR, config); - } catch ( Exception ex ) { - - logger.log( Level.SEVERE, "Fail to save this image file.", ex ); - SkinUtil.openMessage( shell, null, "Fail to save this image file.", SWT.ERROR, config ); String path = fileDialog.open(); - saveFile( path, fileDialog ); - + saveFile(path, fileDialog); } finally { - IOUtil.close( fos ); + IOUtil.close(fos); } - } - public void open() { - - if ( shell.isDisposed() ) { + public void open() throws ScreenShotException { + if (shell.isDisposed()) { return; } - shell.open(); - - /* while ( !shell.isDisposed() ) { - if ( !shell.getDisplay().readAndDispatch() ) { - if ( reserveImage ) { - break; - } else { - shell.getDisplay().sleep(); - } - } - } */ - - } + try { + clickShutter(); + } catch (ScreenShotException e) { + shell.close(); - public void setEmulatorSkin( EmulatorSkin emulatorSkin ) { - this.emulatorSkin = emulatorSkin; - } + throw e; + } - public void setReserveImage( boolean reserveImage ) { - this.reserveImage = reserveImage; + shell.open(); } public Shell getShell() { return shell; } - } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/SdlScreenShotWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/SdlScreenShotWindow.java index 4b049b17fa..a1d93cac18 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/SdlScreenShotWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/SdlScreenShotWindow.java @@ -1,5 +1,5 @@ /** - * Capture a screenshot of the Emulator framebuffer + * Screenshot Window * * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * @@ -32,14 +32,13 @@ import java.util.logging.Logger; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import org.tizen.emulator.skin.EmulatorSdlSkin; import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo; import org.tizen.emulator.skin.comm.ICommunicator.SendCommand; import org.tizen.emulator.skin.comm.sock.SocketCommunicator.DataTranfer; import org.tizen.emulator.skin.config.EmulatorConfig; -import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants; import org.tizen.emulator.skin.exception.ScreenShotException; import org.tizen.emulator.skin.log.SkinLogger; @@ -47,41 +46,44 @@ public class SdlScreenShotWindow extends ScreenShotDialog { private static Logger logger = SkinLogger.getSkinLogger( SdlScreenShotWindow.class).getLogger(); + private PaletteData palette; + /** * @brief constructor * @param Image icon : screenshot window icon resource */ - public SdlScreenShotWindow(Shell parent, - EmulatorSdlSkin emulatorSkin, EmulatorConfig config, - Image icon) throws ScreenShotException { - super(parent, emulatorSkin, config, icon); + public SdlScreenShotWindow(EmulatorSdlSkin emulatorSkin, + EmulatorConfig config, PaletteData palette, Image icon) { + super(emulatorSkin, config, icon); + + this.palette = palette; } protected void capture() throws ScreenShotException { logger.info("screenshot capture"); - DataTranfer dataTranfer = emulatorSkin.communicator.sendDataToQEMU( + DataTranfer dataTranfer = skin.communicator.sendDataToQEMU( SendCommand.SEND_SCREENSHOT_REQ, null, true); byte[] receivedData = - emulatorSkin.communicator.getReceivedData(dataTranfer); + skin.communicator.getReceivedData(dataTranfer); if (null != receivedData) { - int width = config.getArgInt(ArgsConstants.RESOLUTION_WIDTH); - int height = config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT); - ImageData imageData = new ImageData( - width, height, 32, paletteData_BGRA, 1, receivedData); + int width = skin.getEmulatorSkinState().getCurrentResolutionWidth(); + int height = skin.getEmulatorSkinState().getCurrentResolutionHeight(); + ImageData imageData = new ImageData(width, height, + EmulatorSdlSkin.DISPLAY_COLOR_DEPTH, palette, 1, receivedData); RotationInfo rotation = getCurrentRotation(); imageData = rotateImageData(imageData, rotation); - - Image tempImage = image; - image = new Image(Display.getDefault(), imageData); + + Image tempImage = imageFrame; + imageFrame = new Image(Display.getDefault(), imageData); if (tempImage != null) { tempImage.dispose(); } - imageCanvas.redraw(); + canvasFrame.redraw(); } else { throw new ScreenShotException("Fail to get image data."); } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ShmScreenShotWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ShmScreenShotWindow.java index 401b55516b..eef47d3ab0 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ShmScreenShotWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ShmScreenShotWindow.java @@ -1,5 +1,5 @@ /** - * Capture a screenshot of the Emulator framebuffer + * Screenshot Window * * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * @@ -32,12 +32,11 @@ import java.util.logging.Logger; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import org.tizen.emulator.skin.EmulatorShmSkin; import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo; import org.tizen.emulator.skin.config.EmulatorConfig; -import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants; import org.tizen.emulator.skin.exception.ScreenShotException; import org.tizen.emulator.skin.log.SkinLogger; @@ -45,29 +44,32 @@ public class ShmScreenShotWindow extends ScreenShotDialog { private static Logger logger = SkinLogger.getSkinLogger( ShmScreenShotWindow.class).getLogger(); + private PaletteData palette; + /** * @brief constructor * @param Image icon : screenshot window icon resource */ - public ShmScreenShotWindow(Shell parent, - EmulatorShmSkin emulatorSkin, EmulatorConfig config, - Image icon) throws ScreenShotException { - super(parent, emulatorSkin, config, icon); + public ShmScreenShotWindow(EmulatorShmSkin emulatorSkin, + EmulatorConfig config, PaletteData palette, Image icon) { + super(emulatorSkin, config, icon); + + this.palette = palette; } protected void capture() throws ScreenShotException { logger.info("screenshot capture"); - int width = config.getArgInt(ArgsConstants.RESOLUTION_WIDTH); - int height = config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT); - + int width = skin.getEmulatorSkinState().getCurrentResolutionWidth(); + int height = skin.getEmulatorSkinState().getCurrentResolutionHeight(); int[] arrayFramebuffer = new int[width * height]; //int result = - ((EmulatorShmSkin) emulatorSkin).getPixels(arrayFramebuffer); + ((EmulatorShmSkin) skin).getPixels(arrayFramebuffer); //logger.info("getPixels native function returned " + result); - ImageData imageData = new ImageData(width, height, 24, paletteData_ARGB); + ImageData imageData = new ImageData(width, height, + EmulatorShmSkin.DISPLAY_COLOR_DEPTH, palette); /* from shared memory */ imageData.setPixels(0, 0, width * height, arrayFramebuffer, 0); @@ -75,13 +77,13 @@ public class ShmScreenShotWindow extends ScreenShotDialog { RotationInfo rotation = getCurrentRotation(); imageData = rotateImageData(imageData, rotation); - Image tempImage = image; - image = new Image(Display.getDefault(), imageData); + Image tempImage = imageFrame; + imageFrame = new Image(Display.getDefault(), imageData); if (tempImage != null) { tempImage.dispose(); } - imageCanvas.redraw(); + canvasFrame.redraw(); } } \ No newline at end of file