mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-31 18:46:29 +03:00
Added JpegQuality to cImage to set the jpg image save quality.
This commit is contained in:
@@ -15,6 +15,12 @@ namespace EE { namespace Graphics {
|
||||
|
||||
class EE_API cImage {
|
||||
public:
|
||||
/** @return The current Jpeg save quality */
|
||||
static Uint32 JpegQuality();
|
||||
|
||||
/** Set the save quality of Jpeg files ( between 0 and 100 ) */
|
||||
static void JpegQuality( Uint32 level );
|
||||
|
||||
/** @return The File Extension of a Save Type */
|
||||
static std::string SaveTypeToExtension( const Int32& Format );
|
||||
|
||||
@@ -125,6 +131,8 @@ class EE_API cImage {
|
||||
/** Set as true if you dont want to free the image data ( false as default ). */
|
||||
void AvoidFreeImage( const bool& AvoidFree ) { mAvoidFree = AvoidFree; }
|
||||
protected:
|
||||
static Uint32 sJpegQuality;
|
||||
|
||||
Uint8 * mPixels;
|
||||
eeUint mWidth;
|
||||
eeUint mHeight;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by Qt Creator 2.6.0, 2012-12-08T21:40:17. -->
|
||||
<!-- Written by Qt Creator 2.6.0, 2012-12-08T22:45:36. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
|
||||
@@ -485,7 +485,7 @@ void cConsole::CmdGetTextureMemory ( const std::vector < String >& params ) {
|
||||
void cConsole::CmdCmdList ( const std::vector < String >& params ) {
|
||||
std::map < String, ConsoleCallback >::iterator itr;
|
||||
for (itr = mCallbacks.begin(); itr != mCallbacks.end(); itr++) {
|
||||
PushText( itr->first );
|
||||
PushText( "\t" + itr->first );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,17 @@
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
Uint32 cImage::sJpegQuality = 85;
|
||||
|
||||
Uint32 cImage::JpegQuality() {
|
||||
return sJpegQuality;
|
||||
}
|
||||
|
||||
void cImage::JpegQuality( Uint32 level ) {
|
||||
level = eemin( level, (Uint32)100 );
|
||||
sJpegQuality = level;
|
||||
}
|
||||
|
||||
std::string cImage::SaveTypeToExtension( const Int32& Format ) {
|
||||
switch( Format ) {
|
||||
case EE_SAVE_TYPE_TGA: return "tga";
|
||||
@@ -272,6 +283,7 @@ bool cImage::SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Format
|
||||
Res = 0 != ( SOIL_save_image ( filepath.c_str(), Format, (Int32)mWidth, (Int32)mHeight, mChannels, GetPixelsPtr() ) );
|
||||
} else {
|
||||
jpge::params params;
|
||||
params.m_quality = JpegQuality();
|
||||
Res = jpge::compress_image_to_jpeg_file( filepath.c_str(), mWidth, mHeight, mChannels, GetPixelsPtr(), params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,6 +393,7 @@ bool cSubTexture::SaveToFile(const std::string& filepath, const EE_SAVE_TYPE& Fo
|
||||
Res = 0 != ( SOIL_save_image ( filepath.c_str(), Format, RealSize().Width(), RealSize().Height(), 4, GetPixelsPtr() ) );
|
||||
} else {
|
||||
jpge::params params;
|
||||
params.m_quality = cImage::JpegQuality();
|
||||
Res = jpge::compress_image_to_jpeg_file( filepath.c_str(), RealSize().Width(), RealSize().Height(), 4, GetPixelsPtr(), params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,6 +252,7 @@ bool cTextureFactory::SaveImage( const std::string& filepath, const EE_SAVE_TYPE
|
||||
Res = 0 != SOIL_save_image ( filepath.c_str(), Format, Width, Height, Channels, data );
|
||||
} else {
|
||||
jpge::params params;
|
||||
params.m_quality = cImage::JpegQuality();
|
||||
Res = jpge::compress_image_to_jpeg_file( filepath.c_str(), Width, Height, Channels, data, params);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user