mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-24 00:55:07 +03:00
GPSProcessingMethod and UserComment in EXIF tags can be in UTF-16. Expand setString to take an encoding when the field type is undefined. Update callers accordingly. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
71 lines
1.6 KiB
C++
71 lines
1.6 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2020, Google Inc.
|
|
*
|
|
* exif.h - EXIF tag creator using libexif
|
|
*/
|
|
#ifndef __ANDROID_JPEG_EXIF_H__
|
|
#define __ANDROID_JPEG_EXIF_H__
|
|
|
|
#include <string>
|
|
#include <time.h>
|
|
|
|
#include <libexif/exif-data.h>
|
|
|
|
#include <libcamera/geometry.h>
|
|
#include <libcamera/span.h>
|
|
|
|
class Exif
|
|
{
|
|
public:
|
|
Exif();
|
|
~Exif();
|
|
|
|
enum Compression {
|
|
None = 1,
|
|
JPEG = 6,
|
|
};
|
|
|
|
enum StringEncoding {
|
|
NoEncoding = 0,
|
|
ASCII = 1,
|
|
Unicode = 2,
|
|
};
|
|
|
|
void setMake(const std::string &make);
|
|
void setModel(const std::string &model);
|
|
|
|
void setOrientation(int orientation);
|
|
void setSize(const libcamera::Size &size);
|
|
void setThumbnail(libcamera::Span<const unsigned char> thumbnail,
|
|
Compression compression);
|
|
void setTimestamp(time_t timestamp);
|
|
|
|
libcamera::Span<const uint8_t> data() const { return { exifData_, size_ }; }
|
|
[[nodiscard]] int generate();
|
|
|
|
private:
|
|
ExifEntry *createEntry(ExifIfd ifd, ExifTag tag);
|
|
ExifEntry *createEntry(ExifIfd ifd, ExifTag tag, ExifFormat format,
|
|
unsigned long components, unsigned int size);
|
|
|
|
void setShort(ExifIfd ifd, ExifTag tag, uint16_t item);
|
|
void setLong(ExifIfd ifd, ExifTag tag, uint32_t item);
|
|
void setString(ExifIfd ifd, ExifTag tag, ExifFormat format,
|
|
const std::string &item,
|
|
StringEncoding encoding = NoEncoding);
|
|
void setRational(ExifIfd ifd, ExifTag tag, ExifRational item);
|
|
|
|
std::u16string utf8ToUtf16(const std::string &str);
|
|
|
|
bool valid_;
|
|
|
|
ExifData *data_;
|
|
ExifMem *mem_;
|
|
ExifByteOrder order_;
|
|
|
|
unsigned char *exifData_;
|
|
unsigned int size_;
|
|
};
|
|
|
|
#endif /* __ANDROID_JPEG_EXIF_H__ */
|