From 1cea79b4738502071f1bbaf44aa37f56a46d6eac Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Thu, 7 Jan 2016 20:42:31 +0100 Subject: camera: add Pixel{X,Y}Dimension and Orientation EXIF tags These tags are needed by the CM13 camera to not crop images to square when shooting portrait. As the camera HAL already rotated the picture, always set orientation to 0. Change-Id: Id8b6aac5369ae3adfdfec0ec7528edc849bd3b10 --- camera/OMXCameraAdapter/OMXExif.cpp | 34 +++++++++++++++++++++++++++++++--- camera/inc/Encoder_libjpeg.h | 2 ++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/camera/OMXCameraAdapter/OMXExif.cpp b/camera/OMXCameraAdapter/OMXExif.cpp index b4fde5a..f9ed59d 100644 --- a/camera/OMXCameraAdapter/OMXExif.cpp +++ b/camera/OMXCameraAdapter/OMXExif.cpp @@ -237,7 +237,7 @@ status_t OMXCameraAdapter::setupEXIF() struct timeval sTv; struct tm *pTime; OMXCameraPortParameters * capData = NULL; - CameraBuffer *memmgr_buf_array; + CameraBuffer *memmgr_buf_array = NULL; int buf_size = 0; LOG_FUNCTION_NAME; @@ -373,6 +373,28 @@ status_t OMXCameraAdapter::setupEXIF() exifTags->eStatusImageHeight = OMX_TI_TagUpdated; } + if ( OMX_TI_TagReadWrite == exifTags->eStatusPixelXDimension && + OMX_TI_TagReadWrite == exifTags->eStatusPixelYDimension) + { + if (mPictureRotation == 90 || mPictureRotation == 270) { + exifTags->ulPixelXDimension = capData->mHeight; + exifTags->ulPixelYDimension = capData->mWidth; + } + else + { + exifTags->ulPixelXDimension = capData->mWidth; + exifTags->ulPixelYDimension = capData->mHeight; + } + exifTags->eStatusPixelXDimension = OMX_TI_TagUpdated; + exifTags->eStatusPixelYDimension = OMX_TI_TagUpdated; + } + + if ( OMX_TI_TagReadWrite == exifTags->eStatusOrientation) + { + exifTags->usOrientation = 0; + exifTags->eStatusOrientation = OMX_TI_TagUpdated; + } + if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsLatitude ) && ( mEXIFData.mGPSData.mLatValid ) ) { @@ -560,14 +582,20 @@ status_t OMXCameraAdapter::setupEXIF_libjpeg(ExifElementsTable* exifTable, if ((NO_ERROR == ret)) { char temp_value[5]; - snprintf(temp_value, sizeof(temp_value)/sizeof(char), "%lu", capData->mWidth); + snprintf(temp_value, sizeof(temp_value)/sizeof(char), "%lu", (unsigned long)capData->mWidth); ret = exifTable->insertElement(TAG_IMAGE_WIDTH, temp_value); + if ((NO_ERROR == ret)) { + ret = exifTable->insertElement(TAG_EXIF_IMAGE_WIDTH, temp_value); + } } if ((NO_ERROR == ret)) { char temp_value[5]; - snprintf(temp_value, sizeof(temp_value)/sizeof(char), "%lu", capData->mHeight); + snprintf(temp_value, sizeof(temp_value)/sizeof(char), "%lu", (unsigned long)capData->mHeight); ret = exifTable->insertElement(TAG_IMAGE_LENGTH, temp_value); + if ((NO_ERROR == ret)) { + ret = exifTable->insertElement(TAG_EXIF_IMAGE_LENGTH, temp_value); + } } if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mLatValid)) { diff --git a/camera/inc/Encoder_libjpeg.h b/camera/inc/Encoder_libjpeg.h index 72feb08..bb41562 100644 --- a/camera/inc/Encoder_libjpeg.h +++ b/camera/inc/Encoder_libjpeg.h @@ -63,6 +63,8 @@ static const char TAG_FOCALLENGTH[] = "FocalLength"; static const char TAG_DATETIME[] = "DateTime"; static const char TAG_IMAGE_WIDTH[] = "ImageWidth"; static const char TAG_IMAGE_LENGTH[] = "ImageLength"; +static const char TAG_EXIF_IMAGE_WIDTH[] = "ExifImageWidth"; +static const char TAG_EXIF_IMAGE_LENGTH[] = "ExifImageLength"; static const char TAG_GPS_LAT[] = "GPSLatitude"; static const char TAG_GPS_LAT_REF[] = "GPSLatitudeRef"; static const char TAG_GPS_LONG[] = "GPSLongitude"; -- cgit v1.1