Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions indra/llimage/llimagedimensionsinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "stdtypes.h"

#include "llimagejpeg.h"
#include "llimagej2c.h"

#include "llimagedimensionsinfo.h"

Expand Down Expand Up @@ -63,6 +64,8 @@ bool LLImageDimensionsInfo::load(const std::string& src_filename,U32 codec)
return getImageDimensionsTga();
case IMG_CODEC_JPEG:
return getImageDimensionsJpeg();
case IMG_CODEC_J2C:
return getImageDimensionsJ2c();
case IMG_CODEC_PNG:
return getImageDimensionsPng();
default:
Expand Down Expand Up @@ -214,6 +217,23 @@ bool LLImageDimensionsInfo::getImageDimensionsJpeg()
return !sJpegErrorEncountered;
}

bool LLImageDimensionsInfo::getImageDimensionsJ2c()
{
clean();

LLPointer<LLImageJ2C> jpeg_image = new LLImageJ2C;
if (jpeg_image->load(mSrcFilename))
{
mWidth = jpeg_image->getWidth();
mHeight = jpeg_image->getHeight();
return true;
}
mWarning = "texture_load_format_error";
LL_WARNS() << "J2C load error: " << LLImage::getLastThreadError() << LL_ENDL;

return false;
}

bool LLImageDimensionsInfo::checkFileLength(S32 min_len)
{
// Make sure the file is not shorter than min_len bytes.
Expand Down
1 change: 1 addition & 0 deletions indra/llimage/llimagedimensionsinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class LLImageDimensionsInfo
bool getImageDimensionsTga();
bool getImageDimensionsPng();
bool getImageDimensionsJpeg();
bool getImageDimensionsJ2c();

S32 read_s32()
{
Expand Down
6 changes: 4 additions & 2 deletions indra/newview/llfilepicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ LLFilePicker LLFilePicker::sInstance;

#if LL_WINDOWS
#define SOUND_FILTER L"Sounds (*.wav)\0*.wav\0"
#define IMAGE_FILTER L"Images (*.tga; *.bmp; *.jpg; *.jpeg; *.png)\0*.tga;*.bmp;*.jpg;*.jpeg;*.png\0"
#define IMAGE_FILTER L"Images (*.tga; *.bmp; *.jpg; *.jpeg; *.j2c; *.jp2; *.png)\0*.tga;*.bmp;*.jpg;*.jpeg;*.j2c;*.jp2;*.png\0"
#define ANIM_FILTER L"Animations (*.bvh; *.anim)\0*.bvh;*.anim\0"
#define COLLADA_FILTER L"Scene (*.dae)\0*.dae\0"
#define GLTF_FILTER L"glTF (*.gltf; *.glb)\0*.gltf;*.glb\0"
Expand Down Expand Up @@ -559,7 +559,7 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
}
mOFN.lpstrDefExt = L"j2c";
mOFN.lpstrFilter =
L"Compressed Images (*.j2c)\0*.j2c\0" \
L"Compressed Images (*.j2c *.jp2)\0*.j2c;*.jp2\0" \
L"\0";
break;
case FFSAVE_SCRIPT:
Expand Down Expand Up @@ -649,6 +649,8 @@ std::unique_ptr<std::vector<std::string>> LLFilePicker::navOpenFilterProc(ELoadF
case FFLOAD_IMAGE:
allowedv->push_back("jpg");
allowedv->push_back("jpeg");
allowedv->push_back("j2c");
allowedv->push_back("jp2");
allowedv->push_back("bmp");
allowedv->push_back("tga");
allowedv->push_back("bmpf");
Expand Down
20 changes: 20 additions & 0 deletions indra/newview/lllocalbitmaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
/* image compression headers. */
#include "llimagebmp.h"
#include "llimagetga.h"
#include "llimagej2c.h"
#include "llimagejpeg.h"
#include "llimagepng.h"

Expand Down Expand Up @@ -106,6 +107,10 @@ LLLocalBitmap::LLLocalBitmap(std::string filename)
{
mExtension = ET_IMG_JPG;
}
else if (temp_exten == "j2c" || temp_exten == "jp2")
{
mExtension = ET_IMG_J2C;
}
else if (temp_exten == "png")
{
mExtension = ET_IMG_PNG;
Expand Down Expand Up @@ -356,6 +361,21 @@ bool LLLocalBitmap::decodeBitmap(LLPointer<LLImageRaw> rawimg)
break;
}

case ET_IMG_J2C:
{
LLPointer<LLImageJ2C> jpeg_image = new LLImageJ2C;
if (jpeg_image->load(mFilename))
{
jpeg_image->setDiscardLevel(0);
if (jpeg_image->decode(rawimg, 0.0f))
{
rawimg->biasedScaleToPowerOfTwo(LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT);
decode_successful = true;
}
}
break;
}

case ET_IMG_PNG:
{
LLPointer<LLImagePNG> png_image = new LLImagePNG;
Expand Down
1 change: 1 addition & 0 deletions indra/newview/lllocalbitmaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class LLLocalBitmap
ET_IMG_BMP,
ET_IMG_TGA,
ET_IMG_JPG,
ET_IMG_J2C,
ET_IMG_PNG
};

Expand Down
2 changes: 1 addition & 1 deletion indra/newview/llviewermenufile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void LLMediaFilePicker::notify(const std::vector<std::string>& filenames)

#if LL_WINDOWS
static std::string SOUND_EXTENSIONS = "wav";
static std::string IMAGE_EXTENSIONS = "tga bmp jpg jpeg png";
static std::string IMAGE_EXTENSIONS = "tga bmp jpg jpeg j2c jp2 png";
static std::string ANIM_EXTENSIONS = "bvh anim";
static std::string XML_EXTENSIONS = "xml";
static std::string SLOBJECT_EXTENSIONS = "slobject";
Expand Down
9 changes: 9 additions & 0 deletions indra/newview/llviewertexturelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,15 @@ bool LLViewerTextureList::createUploadFile(const std::string& filename,
image->setLastError("Couldn't load the image to be uploaded.");
return false;
}

// calcDataSizeJ2C assumes maximum size is 2048 and for bigger images can
// assign discard to bring imige to needed size, but upload does the scaling
// as needed, so just reset discard.
// Assume file is full and has 'discard' 0 data.
// Todo: probably a better idea to have some setMaxDimentions in J2C
// called when loading from a local file
image->setDiscardLevel(0);

// Decompress or expand it in a raw image structure
LLPointer<LLImageRaw> raw_image = new LLImageRaw;
if (!image->decode(raw_image, 0.0f))
Expand Down