/// <summary> /// Set the resolution of Jpeg /// </summary> /// <param name="jr">resolution, can be 640x480 or 1280x960</param> /// <param name="compression">compression rate,1x to 45x, default 24x</param> /// <returns>True if success</returns> public bool SetJpegResolution(JpegResolution jr, byte compression) { byte returnValue = 255; if (compression > 45) { return(false); } CreatCommand(2, CMD_JPEG_RESOLUTION); CreatCommand(new byte[] { (byte)jr, compression }); SendCommand(id_cmd); SendCommand(para_cmd); if (!ReceiveACK(CMD_JPEG_RESOLUTION, 100, ref returnValue) || returnValue != 0) { throw new Exception("C6820 set jpeg resolution error: " + returnValue.ToString()); } return(true); }
/// <summary> /// Inititate camera with specific settings /// </summary> /// <param name="colorType">Color depth</param> /// <param name="previewResolution">Preview resolution</param> /// <param name="jpegResolution">Jpeg image resolution</param> /// <returns>True if succeeded</returns> public bool Initial(ColorType colorType, PreviewResolution previewResolution, JpegResolution jpegResolution) { // Create the command command[0] = CMD_PREFIX; command[1] = CMD_INITIAL; command[2] = 0; command[3] = (byte)colorType; command[4] = (byte)previewResolution; command[5] = (byte)jpegResolution; // send 'Initial' command SendCommand(command); // Wait for ACK if (!ReceiveACK(CMD_INITIAL, 100)) { return(false); } // Create package size command int packsize = PACKAGE_SIZE; command[0] = CMD_PREFIX; command[1] = CMD_PACKAGESIZE; command[2] = 0x08; command[3] = (byte)packsize; // PACKAGE_SIZE Low byte command[4] = (byte)(packsize >> 8); // PACKAGE_SIZE High byte command[5] = 0x00; // Send 'Set Package Size' command SendCommand(command); // Wait for ACK if (!ReceiveACK(CMD_PACKAGESIZE, 100)) { return(false); } return(true); }
/// <summary> /// Inititate camera with specific settings /// </summary> /// <param name="colorType">Color depth</param> /// <param name="previewResolution">Preview resolution</param> /// <param name="jpegResolution">Jpeg image resolution</param> /// <returns>True if succeeded</returns> public bool Initial(ColorType colorType, PreviewResolution previewResolution, JpegResolution jpegResolution) { // Create the command command[0] = CMD_PREFIX; command[1] = CMD_INITIAL; command[2] = 0; command[3] = (byte)colorType; command[4] = (byte)previewResolution; command[5] = (byte)jpegResolution; // send 'Initial' command SendCommand(command); // Wait for ACK if (! ReceiveACK(CMD_INITIAL)) //100 return false; // Create package size command int packsize = PACKAGE_SIZE; command[0] = CMD_PREFIX; command[1] = CMD_PACKAGESIZE; command[2] = 0x08; command[3] = (byte)packsize; // PACKAGE_SIZE Low byte command[4] = (byte)(packsize >> 8); // PACKAGE_SIZE High byte command[5] = 0x00; // Send 'Set Package Size' command SendCommand(command); // Wait for ACK if (!ReceiveACK(CMD_PACKAGESIZE)) //100 return false; return true; }