Skip to content

Commit

Permalink
Fix and improve code
Browse files Browse the repository at this point in the history
- fix EXIF rotate bug
- update Little-CMS to 2.9
- update upx tool to 3.94
  • Loading branch information
macote committed Feb 14, 2018
1 parent 1e83aee commit d7265b6
Show file tree
Hide file tree
Showing 44 changed files with 762 additions and 566 deletions.
4 changes: 2 additions & 2 deletions .settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="1375034514255234556" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="-1080105969544533125" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="1375034514255234556" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="-1080105969544533125" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
40 changes: 20 additions & 20 deletions 3rd-party/Little-CMS/lcms2.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------------
//
// Little Color Management System
// Copyright (c) 1998-2016 Marti Maria Saguer
// Copyright (c) 1998-2017 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
Expand All @@ -23,7 +23,7 @@
//
//---------------------------------------------------------------------------------
//
// Version 2.8
// Version 2.9rc3
//

#ifndef _lcms2_H
Expand Down Expand Up @@ -78,7 +78,7 @@ extern "C" {
#endif

// Version/release
#define LCMS_VERSION 2080
#define LCMS_VERSION 2090

// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
Expand Down Expand Up @@ -263,18 +263,18 @@ typedef int cmsBool;
#endif

// D50 XYZ normalized to Y=1.0
#define cmsD50X 0.9642
#define cmsD50Y 1.0
#define cmsD50Z 0.8249
#define cmsD50X 0.9642
#define cmsD50Y 1.0
#define cmsD50Z 0.8249

// V4 perceptual black
#define cmsPERCEPTUAL_BLACK_X 0.00336
#define cmsPERCEPTUAL_BLACK_Y 0.0034731
#define cmsPERCEPTUAL_BLACK_Z 0.00287

// Definitions in ICC spec
#define cmsMagicNumber 0x61637370 // 'acsp'
#define lcmsSignature 0x6c636d73 // 'lcms'
#define cmsMagicNumber 0x61637370 // 'acsp'
#define lcmsSignature 0x6c636d73 // 'lcms'


// Base ICC type definitions
Expand Down Expand Up @@ -1133,7 +1133,7 @@ typedef struct {
cmsCIEXYZ whitePoint;
cmsFloat64Number Yb;
cmsFloat64Number La;
int surround;
cmsUInt32Number surround;
cmsFloat64Number D_value;

} cmsViewingConditions;
Expand Down Expand Up @@ -1161,16 +1161,16 @@ typedef struct {
// The internal representation is none of your business.
typedef struct _cms_curve_struct cmsToneCurve;

CMSAPI cmsToneCurve* CMSEXPORT cmsBuildSegmentedToneCurve(cmsContext ContextID, cmsInt32Number nSegments, const cmsCurveSegment Segments[]);
CMSAPI cmsToneCurve* CMSEXPORT cmsBuildSegmentedToneCurve(cmsContext ContextID, cmsUInt32Number nSegments, const cmsCurveSegment Segments[]);
CMSAPI cmsToneCurve* CMSEXPORT cmsBuildParametricToneCurve(cmsContext ContextID, cmsInt32Number Type, const cmsFloat64Number Params[]);
CMSAPI cmsToneCurve* CMSEXPORT cmsBuildGamma(cmsContext ContextID, cmsFloat64Number Gamma);
CMSAPI cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurve16(cmsContext ContextID, cmsInt32Number nEntries, const cmsUInt16Number values[]);
CMSAPI cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurve16(cmsContext ContextID, cmsUInt32Number nEntries, const cmsUInt16Number values[]);
CMSAPI cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cmsUInt32Number nEntries, const cmsFloat32Number values[]);
CMSAPI void CMSEXPORT cmsFreeToneCurve(cmsToneCurve* Curve);
CMSAPI void CMSEXPORT cmsFreeToneCurveTriple(cmsToneCurve* Curve[3]);
CMSAPI cmsToneCurve* CMSEXPORT cmsDupToneCurve(const cmsToneCurve* Src);
CMSAPI cmsToneCurve* CMSEXPORT cmsReverseToneCurve(const cmsToneCurve* InGamma);
CMSAPI cmsToneCurve* CMSEXPORT cmsReverseToneCurveEx(cmsInt32Number nResultSamples, const cmsToneCurve* InGamma);
CMSAPI cmsToneCurve* CMSEXPORT cmsReverseToneCurveEx(cmsUInt32Number nResultSamples, const cmsToneCurve* InGamma);
CMSAPI cmsToneCurve* CMSEXPORT cmsJoinToneCurve(cmsContext ContextID, const cmsToneCurve* X, const cmsToneCurve* Y, cmsUInt32Number nPoints);
CMSAPI cmsBool CMSEXPORT cmsSmoothToneCurve(cmsToneCurve* Tab, cmsFloat64Number lambda);
CMSAPI cmsFloat32Number CMSEXPORT cmsEvalToneCurveFloat(const cmsToneCurve* Curve, cmsFloat32Number v);
Expand Down Expand Up @@ -1215,7 +1215,7 @@ CMSAPI cmsBool CMSEXPORT cmsPipelineSetSaveAs8bitsFlag(cmsPipeline* lu
// Where to place/locate the stages in the pipeline chain
typedef enum { cmsAT_BEGIN, cmsAT_END } cmsStageLoc;

CMSAPI int CMSEXPORT cmsPipelineInsertStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage* mpe);
CMSAPI cmsBool CMSEXPORT cmsPipelineInsertStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage* mpe);
CMSAPI void CMSEXPORT cmsPipelineUnlinkStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage** mpe);

// This function is quite useful to analyze the structure of a Pipeline and retrieve the Stage elements
Expand Down Expand Up @@ -1438,7 +1438,7 @@ CMSAPI cmsBool CMSEXPORT cmsLinkTag(cmsHPROFILE hProfile, cmsTagSignat
CMSAPI cmsTagSignature CMSEXPORT cmsTagLinkedTo(cmsHPROFILE hProfile, cmsTagSignature sig);

// Read and write raw data
CMSAPI cmsInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, void* Buffer, cmsUInt32Number BufferSize);
CMSAPI cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, void* Buffer, cmsUInt32Number BufferSize);
CMSAPI cmsBool CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data, cmsUInt32Number Size);

// Access header data
Expand Down Expand Up @@ -1589,21 +1589,21 @@ CMSAPI cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfileTHR(cmsContext ContextID)
CMSAPI cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfile(void);

CMSAPI cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfileTHR(cmsContext ContextID,
int nLUTPoints,
cmsUInt32Number nLUTPoints,
cmsFloat64Number Bright,
cmsFloat64Number Contrast,
cmsFloat64Number Hue,
cmsFloat64Number Saturation,
int TempSrc,
int TempDest);
cmsUInt32Number TempSrc,
cmsUInt32Number TempDest);

CMSAPI cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfile(int nLUTPoints,
CMSAPI cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfile(cmsUInt32Number nLUTPoints,
cmsFloat64Number Bright,
cmsFloat64Number Contrast,
cmsFloat64Number Hue,
cmsFloat64Number Saturation,
int TempSrc,
int TempDest);
cmsUInt32Number TempSrc,
cmsUInt32Number TempDest);

CMSAPI cmsHPROFILE CMSEXPORT cmsCreateNULLProfileTHR(cmsContext ContextID);
CMSAPI cmsHPROFILE CMSEXPORT cmsCreateNULLProfile(void);
Expand Down
Binary file modified 3rd-party/Little-CMS/lcms2_static.lib
Binary file not shown.
Binary file modified 3rd-party/Little-CMS/liblcms2.a
Binary file not shown.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 1.6.0 (2018-02-10)

- Fix EXIF rotate bug
- Fix delete bug
- Release loaded image thread handles

## 1.5.0 (2017-12-05)

- Update mouse handling code

## 1.4.0 (2017-08-28)

- Support CMYK color in JPEG images
Expand Down
57 changes: 26 additions & 31 deletions CountingSemaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,19 @@
#include <Windows.h>
#include <utility>

class CountingSemaphore
class CountingSemaphore final
{
public:
CountingSemaphore()
CountingSemaphore() { }
CountingSemaphore(LONG maximumcount)
{
}
CountingSemaphore(LONG maximumcount) : maximumcount_(maximumcount)
{
if (maximumcount > 0)
{
SetupSemaphore();
}
SetupSemaphore(maximumcount);
}
~CountingSemaphore()
{
if (semaphore_ != INVALID_HANDLE_VALUE)
{
CloseHandle(semaphore_);
}
Close();
}
CountingSemaphore(const CountingSemaphore&) = delete;
CountingSemaphore(CountingSemaphore&& other)
{
*this = std::move(other);
Expand All @@ -31,53 +24,55 @@ class CountingSemaphore
{
if (this != &other)
{
Close();

semaphore_ = other.semaphore_;
other.semaphore_ = INVALID_HANDLE_VALUE;
}

return *this;
}
void Notify();
void Wait();
LONG maximumcount() const { return maximumcount_; }
void set_maximumcount(LONG maximumcount);
void Notify() const;
void Wait() const;
void SetupSemaphore(LONG maximumcount);
private:
void SetupSemaphore();
LONG maximumcount_{};
void Close()
{
if (semaphore_ != INVALID_HANDLE_VALUE)
{
CloseHandle(semaphore_);
semaphore_ = INVALID_HANDLE_VALUE;
}
}
HANDLE semaphore_{ INVALID_HANDLE_VALUE };
};

inline void CountingSemaphore::set_maximumcount(LONG maximumcount)
inline void CountingSemaphore::SetupSemaphore(LONG maximumcount)
{
maximumcount_ = maximumcount;
SetupSemaphore();
}
Close();

inline void CountingSemaphore::SetupSemaphore()
{
semaphore_ = CreateSemaphore(NULL, maximumcount_, maximumcount_, NULL);
semaphore_ = CreateSemaphore(NULL, maximumcount, maximumcount, NULL);
if (semaphore_ == NULL)
{
// TODO: handle error
}
}

inline void CountingSemaphore::Notify()
inline void CountingSemaphore::Notify() const
{
if (!ReleaseSemaphore(semaphore_, 1, NULL))
{
// TODO: handle error
}
}

inline void CountingSemaphore::Wait()
inline void CountingSemaphore::Wait() const
{
auto waitresult = WaitForSingleObject(semaphore_, INFINITE);
switch (waitresult)
switch (WaitForSingleObject(semaphore_, INFINITE))
{
case WAIT_OBJECT_0:
break;
case WAIT_TIMEOUT:
case WAIT_FAILED:
// TODO: handle unhandled case
break;
}
Expand Down
4 changes: 4 additions & 0 deletions DebugHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class DebugHelper
public:
static std::wstring FormatWindowMessage(MSG msg);
static std::wstring FormatWindowMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
DebugHelper() { }
};

const std::map<UINT, std::wstring> kWindowsMessageCodeMap =
Expand Down Expand Up @@ -272,6 +274,7 @@ inline std::wstring DebugHelper::FormatWindowMessage(MSG msg)
wss << L"lParam: " << std::setw(8) << std::setfill(L'0') << std::hex << msg.lParam << L"; ";
wss << L"time: " << msg.time << L"; ";
wss << L"pt: (" << msg.pt.x << L", " << msg.pt.y << ")";

return wss.str();
}

Expand All @@ -282,5 +285,6 @@ inline std::wstring DebugHelper::FormatWindowMessage(UINT uMsg, WPARAM wParam, L
wss << L"message: " << std::setw(8) << std::setfill(L'0') << std::hex << uMsg << messagecode << L"; ";
wss << L"wParam: " << std::setw(8) << std::setfill(L'0') << std::hex << wParam << L"; ";
wss << L"lParam: " << std::setw(8) << std::setfill(L'0') << std::hex << lParam << L"; ";

return wss.str();
}
Loading

0 comments on commit d7265b6

Please sign in to comment.