bool isValid() const;
MediaType getType() const;
+ void getResolution(int &x, int &y) const;
+
const std::string &getFilePath() const;
ucl::Result getThumbnailPath(ThumbnailPathGetCb cb) const;
MediaItem(MediaType type);
ucl::Result prepare(media_info_h media);
+ ucl::Result prepareImage(image_meta_h imageMeta);
private:
ucl::Result initThumbPath(media_info_h media) const;
const MediaType m_type;
std::string m_mediaId;
std::string m_filePath;
+ int m_resolutionX;
+ int m_resolutionY;
mutable media_info_h m_media;
mutable std::string m_thumbPath;
mutable std::unique_ptr<ThumbCbProxy> m_thumbCbProxy;
struct ItemParams {
int flags;
+ int aspectX;
+ int aspectY;
std::string imagePath;
std::string bgImagePath;
};
MediaItem::MediaItem(const MediaType type) :
m_type(type),
m_media(nullptr),
+ m_resolutionX(0),
+ m_resolutionY(0),
m_isValid(false)
{
}
LOG_RETURN(RES_FAIL, "getProperty(file_path) failed!");
}
+ if (m_type == MediaType::IMAGE) {
+ image_meta_h imageMeta = nullptr;
+ const int ret = media_info_get_image(media, &imageMeta);
+ if ((ret != 0) || !imageMeta) {
+ LOG_RETURN(RES_FAIL, "media_info_get_image() failed: %d", ret);
+ }
+ const Result result = prepareImage(imageMeta);
+ image_meta_destroy(imageMeta);
+ FAIL_RETURN(result, "prepareImage() failed!");
+ }
+
m_isValid = true;
return RES_OK;
}
- Result MediaItem::initThumbPath(media_info_h media) const
+ Result MediaItem::prepareImage(const image_meta_h imageMeta)
+ {
+ if (!getProperty(imageMeta, image_meta_get_width, m_resolutionX)) {
+ LOG_RETURN(RES_FAIL, "getProperty(image_width) failed!");
+ }
+
+ if (!getProperty(imageMeta, image_meta_get_height, m_resolutionY)) {
+ LOG_RETURN(RES_FAIL, "getProperty(image_width) failed!");
+ }
+
+ return RES_OK;
+ }
+
+ Result MediaItem::initThumbPath(const media_info_h media) const
{
if (!getProperty(media, media_info_get_thumbnail_path,
m_thumbPath, true)) {
return m_type;
}
+ void MediaItem::getResolution(int &x, int &y) const
+ {
+ x = m_resolutionX;
+ y = m_resolutionY;
+ }
+
const std::string &MediaItem::getFilePath() const
{
return m_filePath;
return true;
}
-}
+ bool getProperty(image_meta_h imageMeta,
+ int (*get)(image_meta_h imageMeta, int *value),
+ int &result, bool mayBeZero)
+ {
+ const int ret = get(imageMeta, &result);
+ if ((ret != 0) || (!mayBeZero && !result)) {
+ ELOG("get() failed: %d", ret);
+ return false;
+ }
+ return true;
+ }
+}
bool getProperty(media_info_h media,
int (*get)(media_info_h media, char **value),
std::string &result, bool optional = false);
+
+ bool getProperty(image_meta_h imageMeta,
+ int (*get)(image_meta_h imageMeta, int *value),
+ int &result, bool mayBeZero = false);
}
#include "helpers.hpp"
evas_object_image_file_set(*m_bgImage,
params.bgImagePath.c_str(), NULL);
- int w, h;
- evas_object_image_size_get(*m_bgImage, &w, &h);
+ int w = params.aspectX;
+ int h = params.aspectY;
+ if ((w == 0) || (h == 0)) {
+ evas_object_image_size_get(*m_bgImage, &w, &h);
+ }
m_bgImage->setARHint(WidgetARHint::NEITHER, w, h);
makeWhite(*m_bgImage);