예제 #1
0
  public static boolean beginLiveView(final EdsCameraRef camera) {
    EdsError err = EdsError.EDS_ERR_OK;

    NativeLongByReference number = new NativeLongByReference(new NativeLong(1));
    Pointer data = number.getPointer();
    err =
        CanonUtils.setPropertyData(
            camera, EdsPropertyID.kEdsPropID_Evf_Mode, 0, NativeLong.SIZE, data);
    if (err != EdsError.EDS_ERR_OK) {
      System.err.println(
          "Could not start live view (set image mode) (error "
              + err.value()
              + ": "
              + err.name()
              + " - "
              + err.description()
              + ")");
      return false;
    }

    number =
        new NativeLongByReference(
            new NativeLong(EdsEvfOutputDevice.kEdsEvfOutputDevice_PC.value()));
    data = number.getPointer();
    err =
        CanonUtils.setPropertyData(
            camera, EdsPropertyID.kEdsPropID_Evf_OutputDevice, 0, NativeLong.SIZE, data);
    if (err != EdsError.EDS_ERR_OK) {
      System.err.println(
          "Could not start live view (set output device) (error "
              + err.value()
              + ": "
              + err.name()
              + " - "
              + err.description()
              + ")");
      return false;
    }

    return true;
  }
예제 #2
0
  public static boolean endLiveView(final EdsCameraRef camera) {
    EdsError err = EdsError.EDS_ERR_OK;

    NativeLongByReference number =
        new NativeLongByReference(
            new NativeLong(EdsEvfOutputDevice.kEdsEvfOutputDevice_TFT.value()));
    Pointer data = number.getPointer();
    err =
        CanonUtils.setPropertyData(
            camera, EdsPropertyID.kEdsPropID_Evf_OutputDevice, 0, NativeLong.SIZE, data);
    if (err != EdsError.EDS_ERR_OK) {
      /*
       * System.err.println( "Could not end live view (error " +
       * err.value() + ": " + err.name() + " - " +
       * err.description() + ")" );
       */
      return false;
    }

    // TODO: decide whether skip deactivating the live view system. Canon's EOS Utility leaves it
    // enabled, so should consider leaving it enabled as well.
    number = new NativeLongByReference(new NativeLong(0));
    data = number.getPointer();
    err =
        CanonUtils.setPropertyData(
            camera, EdsPropertyID.kEdsPropID_Evf_Mode, 0, NativeLong.SIZE, data);
    if (err != EdsError.EDS_ERR_OK) {
      /*
       * System.err.println( "Could not end live view (error " +
       * err.value() + ": " + err.name() + " - " +
       * err.description() + ")" );
       */
      return false;
    }

    return true;
  }
예제 #3
0
  // TODO: this method isn't very safe to leave public, perhaps some
  // setPropertyData[String/UInt32/etc.] methods would be better
  public static EdsError setPropertyDataAdvanced(
      final EdsBaseRef ref, final EdsPropertyID property, final long param, final Object value)
      throws IllegalStateException {

    final EdsDataType type = CanonUtils.getPropertyType(ref, property, param);

    final Pointer pointer;
    final int size;

    switch (type) {
      case kEdsDataType_String:
        { // EdsChar[]
          final String string = (String) value;
          size = string.length() + 1;
          pointer = new Memory(size);
          pointer.setString(0, string);
          break;
        }
      case kEdsDataType_Int8: // EdsInt8
      case kEdsDataType_UInt8:
        { // EdsUInt8
          size = 1;
          pointer = new Memory(size);
          pointer.setByte(0, (Byte) value);
          break;
        }
      case kEdsDataType_Int16: // EdsInt16
      case kEdsDataType_UInt16:
        { // EdsUInt16
          size = 2;
          pointer = new Memory(size);
          pointer.setShort(0, (Short) value);
          break;
        }
      case kEdsDataType_Int32: // EdsInt32
      case kEdsDataType_UInt32:
        { // EdsUInt32
          size = 4;
          pointer = new Memory(size);
          pointer.setNativeLong(0, new NativeLong((Long) value));
          break;
        }
      case kEdsDataType_Int64: // EdsInt64
      case kEdsDataType_UInt64:
        { // EdsUInt64
          size = 8;
          pointer = new Memory(size);
          pointer.setLong(0, (Long) value);
          break;
        }
      case kEdsDataType_Float:
        { // EdsFloat
          size = 4;
          pointer = new Memory(size);
          pointer.setFloat(0, (Float) value);
          break;
        }
      case kEdsDataType_Double:
        { // EdsDouble
          size = 8;
          pointer = new Memory(size);
          pointer.setDouble(0, (Double) value);
          break;
        }
      case kEdsDataType_ByteBlock:
        { // Byte Block // TODO: According to API, is either EdsInt8[] or EdsUInt32[], but perhaps
          // former is a typo or an old value
          final int[] array = (int[]) value;
          size = 4 * array.length;
          pointer = new Memory(size);
          pointer.write(0, array, 0, array.length);
          break;
        }
      case kEdsDataType_Rational: // EdsRational
      case kEdsDataType_Point: // EdsPoint
      case kEdsDataType_Rect: // EdsRect
      case kEdsDataType_Time: // EdsTime
      case kEdsDataType_FocusInfo: // EdsFocusInfo
      case kEdsDataType_PictureStyleDesc:
        { // EdsPictureStyleDesc
          final Structure structure = (Structure) value;
          structure.write();
          pointer = structure.getPointer();
          size = structure.size();
          break;
        }
      case kEdsDataType_Int8_Array: // EdsInt8[]
      case kEdsDataType_UInt8_Array:
        { // EdsUInt8[]
          final byte[] array = (byte[]) value;
          size = array.length;
          pointer = new Memory(size);
          pointer.write(0, array, 0, array.length);
          break;
        }
      case kEdsDataType_Int16_Array: // EdsInt16[]
      case kEdsDataType_UInt16_Array:
        { // EdsUInt16[]
          final short[] array = (short[]) value;
          size = 2 * array.length;
          pointer = new Memory(size);
          pointer.write(0, array, 0, array.length);
          break;
        }
      case kEdsDataType_Int32_Array: // EdsInt32[]
      case kEdsDataType_UInt32_Array:
        { // EdsUInt32[]
          final int[] array = (int[]) value;
          size = 4 * array.length;
          pointer = new Memory(size);
          pointer.write(0, array, 0, array.length);
          break;
        }
      case kEdsDataType_Bool:
        // EdsBool // TODO: implement
      case kEdsDataType_Bool_Array: // EdsBool[] // TODO: implement
      case kEdsDataType_Rational_Array: // EdsRational[] // TODO: implement
      case kEdsDataType_Unknown: // Unknown
      default:
        throw new IllegalStateException(
            type.description()
                + " ("
                + type.name()
                + ") is not currently supported by GetPropertyCommand");
    }
    return CanonUtils.setPropertyData(ref, property, param, size, pointer);
  }