public ImageViewer(Composite parent, int style) {
    super(parent, style);

    GridLayout gl = new GridLayout(1, false);
    gl.horizontalSpacing = 0;
    gl.verticalSpacing = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    setLayout(gl);

    canvas = new ImageViewCanvas(this, SWT.NONE);
    canvas.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Add DND support
    Transfer[] types = new Transfer[] {ImageTransfer.getInstance()};
    int operations = DND.DROP_COPY;

    final DragSource source = new DragSource(canvas, operations);
    source.setTransfer(types);
    source.addDragListener(
        new DragSourceListener() {
          @Override
          public void dragStart(DragSourceEvent event) {}

          @Override
          public void dragSetData(DragSourceEvent event) {
            if (canvas.getImageData() != null) {
              event.data = canvas.getImageData();
            } else {
              event.data = null;
            }
          }

          @Override
          public void dragFinished(DragSourceEvent event) {}
        });
  }
 public SWTException getLastError() {
   return canvas.getError();
 }
 public boolean clearImage() {
   canvas.loadImage(null);
   return true;
 }
 public boolean loadImage(InputStream inputStream) {
   canvas.loadImage(inputStream);
   return canvas.getError() == null;
 }