framebuffer/pictureviewer: add functions to query icon size

Add infrastructure to query icon size as in tuxbox neutrino.
TODO: those functions are yet to be tested for non-.raw icons ;)

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@44 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
seife
2009-12-13 18:10:29 +00:00
parent 83d7657b9d
commit af169c19ff
4 changed files with 89 additions and 0 deletions

View File

@@ -814,6 +814,70 @@ void CFrameBuffer::setIconBasePath(const std::string & iconPath)
iconBasePath = iconPath;
}
int CFrameBuffer::getIconHeight(const char * const filename)
{
struct rawHeader header;
uint16_t height;
int icon_fd;
char *ptr = rindex(filename, '.');
if (ptr) {
*ptr = 0;
std::string newname = iconBasePath + std::string(filename) + ".gif";
*ptr = '.';
if (!access(newname.c_str(), F_OK))
return g_PicViewer->getHeight(newname.c_str());
}
icon_fd = open(filename, O_RDONLY);
if (icon_fd == -1)
{
printf("Framebuffer getIconHeight: error while loading icon: %s\n", filename);
return 0;
}
else
{
read(icon_fd, &header, sizeof(struct rawHeader));
height = (header.height_hi << 8) | header.height_lo;
}
close(icon_fd);
return height;
}
int CFrameBuffer::getIconWidth(const char * const filename)
{
struct rawHeader header;
uint16_t width;
int icon_fd;
char *ptr = rindex(filename, '.');
if (ptr) {
*ptr = 0;
std::string newname = iconBasePath + std::string(filename) + ".gif";
*ptr = '.';
if (!access(newname.c_str(), F_OK))
return g_PicViewer->getWidth(newname.c_str());
}
icon_fd = open(filename, O_RDONLY);
if (icon_fd == -1)
{
printf("Framebuffer getIconWidth: error while loading icon: %s\n", filename);
width = 0;
}
else
{
read(icon_fd, &header, sizeof(struct rawHeader));
width = (header.width_hi << 8) | header.width_lo;
}
close(icon_fd);
return width;
}
bool CFrameBuffer::paintIcon8(const std::string & filename, const int x, const int y, const unsigned char offset)
{
if (!getActive())