2 * Copyright (C) 2021 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "InfoTagPicture.h"
11 #include "AddonUtils.h"
12 #include "guilib/guiinfo/GUIInfoLabels.h"
13 #include "interfaces/legacy/Exception.h"
14 #include "pictures/PictureInfoTag.h"
15 #include "utils/StringUtils.h"
17 using namespace XBMCAddonUtils
;
24 InfoTagPicture::InfoTagPicture(bool offscreen
/* = false */)
25 : infoTag(new CPictureInfoTag
), offscreen(offscreen
), owned(true)
29 InfoTagPicture::InfoTagPicture(const CPictureInfoTag
* tag
)
30 : infoTag(new CPictureInfoTag(*tag
)), offscreen(true), owned(true)
34 InfoTagPicture::InfoTagPicture(CPictureInfoTag
* tag
, bool offscreen
/* = false */)
35 : infoTag(tag
), offscreen(offscreen
), owned(false)
39 InfoTagPicture::~InfoTagPicture()
45 String
InfoTagPicture::getResolution()
47 return infoTag
->GetInfo(SLIDESHOW_RESOLUTION
);
50 String
InfoTagPicture::getDateTimeTaken()
52 return infoTag
->GetDateTimeTaken().GetAsW3CDateTime();
55 void InfoTagPicture::setResolution(int width
, int height
)
57 XBMCAddonUtils::GuiLock
lock(languageHook
, offscreen
);
58 setResolutionRaw(infoTag
, width
, height
);
61 void InfoTagPicture::setDateTimeTaken(const String
& datetimetaken
)
63 XBMCAddonUtils::GuiLock
lock(languageHook
, offscreen
);
64 setDateTimeTakenRaw(infoTag
, datetimetaken
);
67 void InfoTagPicture::setResolutionRaw(CPictureInfoTag
* infoTag
, const String
& resolution
)
69 infoTag
->SetInfo("resolution", resolution
);
72 void InfoTagPicture::setResolutionRaw(CPictureInfoTag
* infoTag
, int width
, int height
)
75 throw WrongTypeException("InfoTagPicture.setResolution: width must be greater than zero (0)");
77 throw WrongTypeException("InfoTagPicture.setResolution: height must be greater than zero (0)");
79 setResolutionRaw(infoTag
, StringUtils::Format("{:d},{:d}", width
, height
));
82 void InfoTagPicture::setDateTimeTakenRaw(CPictureInfoTag
* infoTag
, String datetimetaken
)
84 // try to parse the datetimetaken as from W3C format and adjust it to the EXIF datetime format YYYY:MM:DD HH:MM:SS
85 CDateTime w3cDateTimeTaken
;
86 if (w3cDateTimeTaken
.SetFromW3CDateTime(datetimetaken
))
88 datetimetaken
= StringUtils::Format("{:4d}:{:2d}:{:2d} {:2d}:{:2d}:{:2d}",
89 w3cDateTimeTaken
.GetYear(), w3cDateTimeTaken
.GetMonth(),
90 w3cDateTimeTaken
.GetDay(), w3cDateTimeTaken
.GetHour(),
91 w3cDateTimeTaken
.GetMinute(), w3cDateTimeTaken
.GetSecond());
94 infoTag
->SetInfo("exiftime", datetimetaken
);
98 } // namespace XBMCAddon