Пример #1
0
 protected void copyRGB(RGB src, RGB dst) {
   dst.red = src.red;
   dst.green = src.green;
   dst.blue = src.blue;
 }
Пример #2
0
  @Override
  public Image run(Image input, int imageType) {

    ImageData inData = input.getImageData(); // Die echten Bilddaten sind hier drin

    // RGB zu YUV Umwandlungsmatrix
    //		double[] linear_conversion = {
    //			0.2126, 0.7152, 0.0722,
    //			-0.09991, -0.33609, 0.436,
    //			0.615, -0.55861, -0.05639
    //		};
    double[] linear_conversion = {0.299, 0.587, 0.114, -0.147, -0.289, 0.436, 0.615, -0.515, -0.1};
    Matrix m = new Matrix(3, 3, linear_conversion);

    // YUV zu RGB Umwandlungmatrix (das Inverse)
    //		double[] inv_linear_conversion = {
    //		    1.0000,    0.0000,    1.28033,
    //		    1.0000,   -0.21482,   -0.38059,
    //		    1.0000,    2.12798,   -0.0005
    //		};
    double[] inv_linear_conversion = {
      1.0000, 0.0000, 1.1398, 1.0000, -0.3946, -0.5805, 1.0000, 2.0320, -0.0005
    };
    Matrix minv = new Matrix(3, 3, inv_linear_conversion);

    for (int v = 0; v < inData.height; v++) {
      for (int u = 0; u < inData.width; u++) {
        int pixel = inData.getPixel(u, v);

        RGB rgb = inData.palette.getRGB(pixel);

        // Variante mit Farbwerte U und V von YUV auf 0 setzen
        Vector r = new Vector(rgb.red, rgb.green, rgb.blue);
        double[] y = m.times(r).getV();
        y[2] = 0;
        y[1] = 0;
        r = minv.times(new Vector(y));
        rgb.red = (int) r.x(1);
        rgb.green = (int) r.x(2);
        rgb.blue = (int) r.x(3);

        if (rgb.red < 0) rgb.red = 0;
        else if (rgb.red > 255) rgb.red = 255;

        if (rgb.green < 0) rgb.green = 0;
        else if (rgb.green > 255) rgb.green = 255;

        if (rgb.blue < 0) rgb.blue = 0;
        else if (rgb.blue > 255) rgb.blue = 255;

        // Variante mit der Sättigung auf 0 gesetzt (schlechter)
        //				float[] hsb = inData.palette.getRGB(pixel).getHSB();
        //
        //				hsb[1] = 0; //Sättigung auf 0 setzen
        //
        //				Color c = new Color(Color.HSBtoRGB(hsb[0],hsb[1],hsb[2]));
        //				RGB rgb = new RGB(0,0,0);
        //				rgb.red = c.getRed();
        //				rgb.green = c.getGreen();
        //				rgb.blue = c.getBlue();

        inData.setPixel(u, v, inData.palette.getPixel(rgb));
      }
    }
    return new Image(input.getDevice(), inData);
  }
Пример #3
0
  /**
   * This methode should be overload by sub class to create the input component for the selection of
   * this input video. The implementation of this class return an empty Composite.
   *
   * @param parent the parent of this Area
   * @return the control created
   */
  protected Control createInputArea(Composite parent) {

    // Setup darker background
    RGB rgb = getBackground().getRGB();
    rgb.red = (int) (rgb.red * DARKER_COLOR_FACTOR);
    rgb.green = (int) (rgb.green * DARKER_COLOR_FACTOR);
    rgb.blue = (int) (rgb.blue * DARKER_COLOR_FACTOR);
    darkerBackground = new Color(Display.getCurrent(), rgb);

    // Create the composite component
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(4, false));

    /*
     * Filename components
     */
    String filenameText = Localization.getString(Localization.INPUTOUTPUT_FILENAME);
    Label label;
    label = new Label(comp, SWT.NONE);
    label.setText(filenameText);
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));

    Composite subComp = new Composite(comp, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    subComp.setLayout(layout);
    subComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));

    inputFileName = new Text(subComp, SWT.READ_ONLY | SWT.BORDER);
    inputFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    createMoreOptionsButton(subComp);

    /*
     * Language selection
     */
    label = new Label(comp, SWT.NONE);
    label.setText(Localization.getString(Localization.INPUTOUTPUT_LANGAGE));
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));

    languageCombo = createViewer(comp, AUDIO_ID);
    languageCombo.getCombo().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));

    /*
     * Subtitle selection
     */
    String subtitleText = Localization.getString(Localization.INPUTOUTPUT_SUBTITLE);
    label = new Label(comp, SWT.NONE);
    label.setText(subtitleText);
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));

    subtitleCombo = createViewer(comp, SUBTITLE_ID);
    subtitleCombo.getCombo().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));

    /*
     * Description label
     */
    label = new Label(comp, SWT.NONE);
    label.setText(Localization.getString(Localization.INPUTOUTPUT_VIDEO));
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));

    videoDescription = new Text(comp, SWT.BORDER | SWT.WRAP | SWT.READ_ONLY);
    videoDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
    videoDescription.setBackground(darkerBackground);

    label = new Label(comp, SWT.NONE);
    label.setText(Localization.getString(Localization.INPUTOUTPUT_AUDIO));
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));

    audioDescription = new Text(comp, SWT.BORDER | SWT.WRAP | SWT.READ_ONLY);
    audioDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
    audioDescription.setBackground(darkerBackground);

    // Add disposal instruction
    this.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            darkerBackground.dispose();
          }
        });

    return comp;
  }