Exemple #1
0
  public static BufferedImage convertImageToRGB(
      CLParams clParams,
      float[] sphericalImageFloats,
      int width,
      int height,
      ConversionType inputType) {

    FloatBuffer fb = Buffers.newDirectFloatBuffer(sphericalImageFloats);
    CLBuffer<FloatBuffer> sphericalImageBuffer =
        clParams.getContext().createBuffer(fb, CLBuffer.Mem.READ_WRITE);

    out.println("Transforming image to rgb coords");
    CLKernel kernel = clParams.getKernel("convert_" + typeToString(inputType) + "_to_rgb");
    kernel.putArg(sphericalImageBuffer).putArg(width).putArg(height).rewind();

    long time = nanoTime();
    clParams.getQueue().putWriteBuffer(sphericalImageBuffer, false);
    clParams.getQueue().put2DRangeKernel(kernel, 0, 0, width, height, 0, 0);
    clParams.getQueue().putReadBuffer(sphericalImageBuffer, true);
    time = nanoTime() - time;
    out.println("computation took: " + (time / 1000000) + "ms");

    BufferedImage rgbImage =
        ImageUtils.createImage(width, height, sphericalImageBuffer, BufferedImage.TYPE_INT_RGB);

    return rgbImage;
  }
 private void show(EditorImageSet editorImage, int index) {
   if (index < editorImage.getImageCount()) {
     ImageDictionary imageDictionary = editorImage.select(index);
     imageWidth.setText("图片宽度:" + imageDictionary.getWidth());
     imageHeight.setText("图片高度:" + imageDictionary.getHeight());
     useEast.setText("" + imageDictionary.getUseEast());
     useSouth.setText("" + imageDictionary.getUseSouth());
     offsetX.setText("" + imageDictionary.getOffsetX());
     offsetY.setText("" + imageDictionary.getOffsetY());
     globalId.setText("" + imageDictionary.getGlobalId());
     isObstacle.setSelection(imageDictionary.getMark() == MapCell.MARK_OBSTACLE);
     color.setText("调色板:" + (imageDictionary.hasColorPalettes() ? "自带" : "全局"));
     ImageEditor.this.image.setImage(
         ImageUtils.createImage(
             ImageEditor.this.image.getDisplay(), imageDictionary.bufferedImage()));
     Rectangle rect = ImageEditor.this.image.getBounds();
     ImageEditor.this.image.setBounds(
         rect.x, rect.y, imageDictionary.getWidth(), imageDictionary.getHeight());
     container.redraw();
   } else if (index != 0) {
     MessageDialog.openError(
         PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "错误", "越界:" + index);
   }
 }