-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for image (en|de)coder add-ons
- Loading branch information
Showing
17 changed files
with
369 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (C) 2013 Arne Morten Kvarving | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
#include "ImageEncoder.h" | ||
|
||
namespace ADDON | ||
{ | ||
|
||
std::unique_ptr<CImageEncoder> | ||
CImageEncoder::FromExtension(AddonProps props, const cp_extension_t* ext) | ||
{ | ||
std::string mime = CAddonMgr::GetInstance().GetExtValue(ext->configuration, "@mimetype"); | ||
return std::unique_ptr<CImageEncoder>(new CImageEncoder(std::move(props), | ||
std::move(mime))); | ||
} | ||
|
||
CImageEncoder::CImageEncoder(AddonProps props, std::string mime) : | ||
ImageEncoderDll(std::move(props)), | ||
m_mimetype(std::move(mime)) | ||
{ | ||
} | ||
|
||
CImageEncoder::~CImageEncoder() | ||
{ | ||
if (m_image && Initialized()) | ||
m_pStruct->Close(m_image); | ||
} | ||
|
||
bool CImageEncoder::LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, | ||
unsigned int width, unsigned int height) | ||
{ | ||
if (!Initialized()) | ||
return false; | ||
|
||
m_width = width; | ||
m_height = height; | ||
m_image = m_pStruct->LoadImage(buffer, bufSize, &m_width, &m_height); | ||
|
||
return m_image != nullptr; | ||
} | ||
|
||
bool CImageEncoder::Decode(unsigned char* const pixels, unsigned int width, | ||
unsigned int height, unsigned int pitch, | ||
unsigned int format) | ||
{ | ||
if (!Initialized()) | ||
return false; | ||
|
||
bool result = m_pStruct->Decode(m_image, pixels, width, height, pitch, format); | ||
m_width = width; | ||
m_height = height; | ||
|
||
return result; | ||
} | ||
|
||
bool CImageEncoder::CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, | ||
unsigned int height, unsigned int format, | ||
unsigned int pitch, const std::string& destFile, | ||
unsigned char*& bufferout, unsigned int& bufferoutSize) | ||
{ | ||
if (!Initialized()) | ||
return false; | ||
|
||
return m_pStruct->CreateThumbnail(bufferin, width, height, pitch, format, destFile.c_str()); | ||
} | ||
|
||
bool CImageEncoder::Create(const std::string& mimetype) | ||
{ | ||
m_pInfo = new IMAGEENC_PROPS; | ||
m_pInfo->mimetype = mimetype.c_str(); | ||
|
||
return ImageEncoderDll::Create(); | ||
} | ||
|
||
} /*namespace ADDON*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2013 Arne Morten Kvarving | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
#pragma once | ||
|
||
#include "AddonDll.h" | ||
#include "addons/kodi-addon-dev-kit/include/kodi/kodi_imageenc_types.h" | ||
#include "guilib/iimage.h" | ||
|
||
typedef DllAddon<ImageEncoder, IMAGEENC_PROPS> DllImageEncoder; | ||
namespace ADDON | ||
{ | ||
typedef CAddonDll<DllImageEncoder, | ||
ImageEncoder, IMAGEENC_PROPS> ImageEncoderDll; | ||
|
||
class CImageEncoder : public ImageEncoderDll, | ||
public IImage | ||
{ | ||
public: | ||
static std::unique_ptr<CImageEncoder> FromExtension(AddonProps, | ||
const cp_extension_t* ext); | ||
explicit CImageEncoder(AddonProps props) : | ||
ImageEncoderDll(std::move(props)) | ||
{} | ||
|
||
CImageEncoder(AddonProps props, std::string mimetypes); | ||
virtual ~CImageEncoder(); | ||
|
||
bool Create(const std::string& mimetype); | ||
|
||
bool LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, | ||
unsigned int width, unsigned int height); | ||
bool Decode(unsigned char* const pixels, unsigned int width, | ||
unsigned int height, unsigned int pitch, | ||
unsigned int format); | ||
bool CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, | ||
unsigned int height, unsigned int format, | ||
unsigned int pitch, const std::string& destFile, | ||
unsigned char*& bufferout, unsigned int& bufferoutSize); | ||
|
||
const std::string& GetMimetypes() const { return m_mimetype; } | ||
protected: | ||
void* m_image = nullptr; | ||
std::string m_mimetype; | ||
}; | ||
|
||
} /*namespace ADDON*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_imageenc_dll.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (C) 2005-2013 Team XBMC | ||
* http://xbmc.org | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include "xbmc_addon_dll.h" | ||
#include "kodi_imageenc_types.h" | ||
|
||
extern "C" | ||
{ | ||
void* LoadImage(unsigned char* buffer, unsigned int bufSize, | ||
unsigned int* width, unsigned int* height); | ||
|
||
bool Decode(void* image, unsigned char* pixels, | ||
unsigned int width, unsigned int height, | ||
unsigned int pitch, unsigned int format); | ||
|
||
bool CreateThumbnail(unsigned char* bufferin, | ||
unsigned int width, | ||
unsigned int height, | ||
unsigned int pitch, | ||
unsigned int format, | ||
const char* destFile); | ||
|
||
void Close(void* image); | ||
|
||
// function to export the above structure to Kodi | ||
void __declspec(dllexport) get_addon(struct ImageEncoder* pEnc) | ||
{ | ||
pEnc->LoadImage = LoadImage; | ||
pEnc->Decode = Decode; | ||
pEnc->CreateThumbnail = CreateThumbnail; | ||
pEnc->Close = Close; | ||
}; | ||
}; |
Oops, something went wrong.