コード例 #1
0
  @Override
  protected final void resetGammaRamp(Buffer originalGammaRamp) {
    if (originalGammaRamp == null) {
      return; // getGammaRamp failed originally
    }
    long display = getOrCreateSharedDpy(defaultDevice);
    if (0 == display) {
      return;
    }

    ShortBuffer rampData = (ShortBuffer) originalGammaRamp;
    int capacity = rampData.capacity();
    if ((capacity % 3) != 0) {
      throw new IllegalArgumentException("Must not be the original gamma ramp");
    }
    int size = capacity / 3;
    rampData.position(0);
    rampData.limit(size);
    ShortBuffer redRampData = rampData.slice();
    rampData.position(size);
    rampData.limit(2 * size);
    ShortBuffer greenRampData = rampData.slice();
    rampData.position(2 * size);
    rampData.limit(3 * size);
    ShortBuffer blueRampData = rampData.slice();

    X11Lib.XF86VidModeSetGammaRamp(
        display, X11Lib.DefaultScreen(display), size, redRampData, greenRampData, blueRampData);
  }
コード例 #2
0
  @Override
  protected final boolean setGammaRamp(float[] ramp) {
    long display = getOrCreateSharedDpy(defaultDevice);
    if (0 == display) {
      return false;
    }

    int len = ramp.length;
    short[] rampData = new short[len];
    for (int i = 0; i < len; i++) {
      rampData[i] = (short) (ramp[i] * 65535);
    }

    boolean res =
        X11Lib.XF86VidModeSetGammaRamp(
            display,
            X11Lib.DefaultScreen(display),
            rampData.length,
            rampData,
            0,
            rampData,
            0,
            rampData,
            0);
    return res;
  }
コード例 #3
0
  private static final void resetGammaRamp(
      final long display, final int screenIdx, final Buffer originalGammaRamp) {
    final ShortBuffer rampData = (ShortBuffer) originalGammaRamp;
    final int capacity = rampData.capacity();
    if ((capacity % 3) != 0) {
      throw new IllegalArgumentException("Must not be the original gamma ramp");
    }
    final int size = capacity / 3;

    final ShortBuffer redRampData = Buffers.slice(rampData, 0 * size, size);
    final ShortBuffer greenRampData = Buffers.slice(rampData, 1 * size, size);
    final ShortBuffer blueRampData = Buffers.slice(rampData, 2 * size, size);
    if (DEBUG) {
      dumpRamp("RESET", size, redRampData, greenRampData, blueRampData);
    }

    X11Lib.XF86VidModeSetGammaRamp(
        display, screenIdx, size, redRampData, greenRampData, blueRampData);
  }
コード例 #4
0
  @Override
  protected final boolean setGammaRamp(final NativeSurface surface, final float[] ramp) {
    final long display = surface.getDisplayHandle();
    if (0 == display) {
      return false;
    }
    final int screenIdx = surface.getScreenIndex();

    final int len = ramp.length;
    final short[] rampData = new short[len];
    for (int i = 0; i < len; i++) {
      rampData[i] = (short) (ramp[i] * 65535);
    }

    final boolean res =
        X11Lib.XF86VidModeSetGammaRamp(
            display, screenIdx, rampData.length, rampData, 0, rampData, 0, rampData, 0);
    if (DEBUG) {
      dumpRamp("SET__", rampData.length, rampData, rampData, rampData);
    }
    return res;
  }