remove tiff (#20047)

This commit is contained in:
minggo 2019-08-20 15:15:40 +08:00 committed by GitHub
parent 19ce98424c
commit 5e40f5e6a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 5 additions and 265 deletions

View File

@ -303,12 +303,6 @@ THE SOFTWARE.
#define CC_USE_JPEG 1
#endif // CC_USE_JPEG
/** Support TIFF or not. If your application don't use TIFF format picture, you can undefine this macro to save package size.
*/
#ifndef CC_USE_TIFF
#define CC_USE_TIFF 1
#endif // CC_USE_TIFF
/** Support webp or not. If your application don't use webp format picture, you can undefine this macro to save package size.
*/
#ifndef CC_USE_WEBP

View File

@ -31,7 +31,7 @@ THE SOFTWARE.
#include <ctype.h>
#include "base/CCData.h"
#include "base/ccConfig.h" // CC_USE_JPEG, CC_USE_TIFF, CC_USE_WEBP
#include "base/ccConfig.h" // CC_USE_JPEG, CC_USE_WEBP
extern "C"
{
@ -82,10 +82,6 @@ extern "C"
#include "png.h"
#endif //CC_USE_PNG
#if CC_USE_TIFF
#include "tiffio.h"
#endif //CC_USE_TIFF
#include "base/etc1.h"
#if CC_USE_JPEG
@ -572,9 +568,6 @@ bool Image::initWithImageData(const unsigned char * data, ssize_t dataLen)
case Format::JPG:
ret = initWithJpgData(unpackedData, unpackedLen);
break;
case Format::TIFF:
ret = initWithTiffData(unpackedData, unpackedLen);
break;
case Format::WEBP:
ret = initWithWebpData(unpackedData, unpackedLen);
break;
@ -672,20 +665,6 @@ bool Image::isJpg(const unsigned char * data, ssize_t dataLen)
return memcmp(data, JPG_SOI, 2) == 0;
}
bool Image::isTiff(const unsigned char * data, ssize_t dataLen)
{
if (dataLen <= 4)
{
return false;
}
static const char* TIFF_II = "II";
static const char* TIFF_MM = "MM";
return (memcmp(data, TIFF_II, 2) == 0 && *(static_cast<const unsigned char*>(data) + 2) == 42 && *(static_cast<const unsigned char*>(data) + 3) == 0) ||
(memcmp(data, TIFF_MM, 2) == 0 && *(static_cast<const unsigned char*>(data) + 2) == 0 && *(static_cast<const unsigned char*>(data) + 3) == 42);
}
bool Image::isWebp(const unsigned char * data, ssize_t dataLen)
{
if (dataLen <= 12)
@ -723,10 +702,6 @@ Image::Format Image::detectFormat(const unsigned char * data, ssize_t dataLen)
{
return Format::JPG;
}
else if (isTiff(data, dataLen))
{
return Format::TIFF;
}
else if (isWebp(data, dataLen))
{
return Format::WEBP;
@ -1077,174 +1052,6 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
#endif //CC_USE_PNG
}
#if CC_USE_TIFF
namespace
{
static tmsize_t tiffReadProc(thandle_t fd, void* buf, tmsize_t size)
{
tImageSource* isource = (tImageSource*)fd;
uint8* ma;
uint64 mb;
unsigned long n;
unsigned long o;
tmsize_t p;
ma=(uint8*)buf;
mb=size;
p=0;
while (mb>0)
{
n=0x80000000UL;
if ((uint64)n>mb)
n=(unsigned long)mb;
if ((int)(isource->offset + n) <= isource->size)
{
memcpy(ma, isource->data+isource->offset, n);
isource->offset += n;
o = n;
}
else
{
return 0;
}
ma+=o;
mb-=o;
p+=o;
if (o!=n)
{
break;
}
}
return p;
}
static tmsize_t tiffWriteProc(thandle_t /*fd*/, void* /*buf*/, tmsize_t /*size*/)
{
return 0;
}
static uint64 tiffSeekProc(thandle_t fd, uint64 off, int whence)
{
tImageSource* isource = (tImageSource*)fd;
uint64 ret = -1;
do
{
if (whence == SEEK_SET)
{
CC_BREAK_IF(off >= (uint64)isource->size);
ret = isource->offset = (uint32)off;
}
else if (whence == SEEK_CUR)
{
CC_BREAK_IF(isource->offset + off >= (uint64)isource->size);
ret = isource->offset += (uint32)off;
}
else if (whence == SEEK_END)
{
CC_BREAK_IF(off >= (uint64)isource->size);
ret = isource->offset = (uint32)(isource->size-1 - off);
}
else
{
CC_BREAK_IF(off >= (uint64)isource->size);
ret = isource->offset = (uint32)off;
}
} while (0);
return ret;
}
static uint64 tiffSizeProc(thandle_t fd)
{
tImageSource* imageSrc = (tImageSource*)fd;
return imageSrc->size;
}
static int tiffCloseProc(thandle_t /*fd*/)
{
return 0;
}
static int tiffMapProc(thandle_t /*fd*/, void** /*base*/, toff_t* /*size*/)
{
return 0;
}
static void tiffUnmapProc(thandle_t /*fd*/, void* /*base*/, toff_t /*size*/)
{
}
}
#endif // CC_USE_TIFF
bool Image::initWithTiffData(const unsigned char * data, ssize_t dataLen)
{
#if CC_USE_TIFF
bool ret = false;
do
{
// set the read call back function
tImageSource imageSource;
imageSource.data = data;
imageSource.size = dataLen;
imageSource.offset = 0;
TIFF* tif = TIFFClientOpen("file.tif", "r", (thandle_t)&imageSource,
tiffReadProc, tiffWriteProc,
tiffSeekProc, tiffCloseProc, tiffSizeProc,
tiffMapProc,
tiffUnmapProc);
CC_BREAK_IF(nullptr == tif);
uint32 w = 0, h = 0;
uint16 bitsPerSample = 0, samplePerPixel = 0, planarConfig = 0;
size_t npixels = 0;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitsPerSample);
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplePerPixel);
TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planarConfig);
npixels = w * h;
_pixelFormat = backend::PixelFormat::RGBA8888;
_width = w;
_height = h;
_dataLen = npixels * sizeof (uint32);
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
uint32* raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));
if (raster != nullptr)
{
if (TIFFReadRGBAImageOriented(tif, w, h, raster, ORIENTATION_TOPLEFT, 0))
{
/* the raster data is pre-multiplied by the alpha component
after invoking TIFFReadRGBAImageOriented*/
_hasPremultipliedAlpha = true;
memcpy(_data, raster, npixels*sizeof (uint32));
}
_TIFFfree(raster);
}
TIFFClose(tif);
ret = true;
} while (0);
return ret;
#else
CCLOG("tiff is not enabled, please enable it in ccConfig.h");
return false;
#endif //CC_USE_TIFF
}
namespace
{
bool testFormatForPvr2TCSupport(PVR2TexturePixelFormat /*format*/)

View File

@ -77,8 +77,6 @@ public:
JPG,
//! PNG
PNG,
//! TIFF
TIFF,
//! WebP
WEBP,
//! PVR
@ -161,7 +159,6 @@ public:
protected:
bool initWithJpgData(const unsigned char * data, ssize_t dataLen);
bool initWithPngData(const unsigned char * data, ssize_t dataLen);
bool initWithTiffData(const unsigned char * data, ssize_t dataLen);
bool initWithWebpData(const unsigned char * data, ssize_t dataLen);
bool initWithPVRData(const unsigned char * data, ssize_t dataLen);
bool initWithPVRv2Data(const unsigned char * data, ssize_t dataLen);
@ -218,7 +215,6 @@ protected:
Format detectFormat(const unsigned char * data, ssize_t dataLen);
bool isPng(const unsigned char * data, ssize_t dataLen);
bool isJpg(const unsigned char * data, ssize_t dataLen);
bool isTiff(const unsigned char * data, ssize_t dataLen);
bool isWebp(const unsigned char * data, ssize_t dataLen);
bool isPvr(const unsigned char * data, ssize_t dataLen);
bool isEtc(const unsigned char * data, ssize_t dataLen);

View File

@ -89,7 +89,7 @@ public:
* If the filename was not previously loaded, it will create a new Texture2D.
* Object and it will return it. It will use the filename as a key.
* Otherwise it will return a reference of a previously loaded image.
* Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr.
* Supported image extensions: .png, .bmp, .jpeg, .pvr.
@param filepath The file path.
*/
Texture2D* addImage(const std::string &filepath);

View File

@ -1,5 +1,5 @@
{
"version": "metal-support-10",
"version": "metal-support-11",
"zip_file_size": "146254799",
"repo_name": "cocos2d-x-3rd-party-libs-bin",
"repo_parent": "https://github.com/cocos2d/",

View File

@ -90,15 +90,7 @@
"include": [
"*.dll"
]
},
{
"from": "external/tiff/prebuilt/win32",
"to": "runtime/win32",
"include": [
"*.dll"
]
}
]
},
"do_add_native_support": {

View File

@ -1031,7 +1031,7 @@ void EaseSpriteDemo::onEnter()
{
TestCase::onEnter();
// Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too
// Or you can create an sprite using a filename. PNG and BMP files are supported.
_grossini = Sprite::create(s_pathGrossini); _grossini->retain();
_tamara = Sprite::create(s_pathSister1); _tamara->retain();
_kathia = Sprite::create(s_pathSister2); _kathia->retain();

View File

@ -106,7 +106,7 @@ void ActionsDemo::onEnter()
{
TestCase::onEnter();
// Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
// Or you can create an sprite using a filename. only PNG is supported now.
_grossini = Sprite::create(s_pathGrossini);
_grossini->retain();

View File

@ -78,7 +78,6 @@ Texture2DTests::Texture2DTests()
ADD_TEST_CASE(TexturePVRBadEncoding);
ADD_TEST_CASE(TexturePNG);
ADD_TEST_CASE(TextureJPEG);
ADD_TEST_CASE(TextureTIFF);
ADD_TEST_CASE(TextureTGA);
ADD_TEST_CASE(TextureWEBP);
ADD_TEST_CASE(TextureWEBPNoAlpha)
@ -132,29 +131,6 @@ TextureDemo::~TextureDemo()
log("%s\n", textureCache->getCachedTextureInfo().c_str());
}
//------------------------------------------------------------------
//
// TextureTIFF
//
//------------------------------------------------------------------
void TextureTIFF::onEnter()
{
TextureDemo::onEnter();
auto s = Director::getInstance()->getWinSize();
auto img = Sprite::create("Images/test_image.tiff");
img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
this->addChild(img);
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
}
std::string TextureTIFF::title() const
{
return "TIFF Test";
}
//------------------------------------------------------------------
//

View File

@ -38,14 +38,6 @@ public:
virtual void onEnter() override;
};
class TextureTIFF : public TextureDemo
{
public:
CREATE_FUNC(TextureTIFF);
virtual std::string title() const override;
virtual void onEnter() override;
};
class TextureTGA : public TextureDemo
{

View File

@ -13,22 +13,6 @@ local function createTestLayer(title, subtitle)
print(cc.Director:getInstance():getTextureCache():getCachedTextureInfo())
return ret
end
--------------------------------------------------------------------
--
-- TextureTIFF
--
--------------------------------------------------------------------
local function TextureTIFF()
local ret = createTestLayer("TIFF Test")
local s = cc.Director:getInstance():getWinSize()
local img = cc.Sprite:create("Images/test_image.tiff")
img:setPosition(cc.p( s.width/2.0, s.height/2.0))
ret:addChild(img)
print(cc.Director:getInstance():getTextureCache():getCachedTextureInfo())
return ret
end
--------------------------------------------------------------------
--
@ -1436,7 +1420,6 @@ function Texture2dTestMain()
TexturePVRBadEncoding,
TexturePNG,
TextureJPEG,
TextureTIFF,
TextureWEBP,
TextureMipMap,
TexturePixelFormat,