Skip to content

Commit

Permalink
fix mistakes that introduced when update compiler to vs2015 and upgra…
Browse files Browse the repository at this point in the history
…de libpng to the latest
  • Loading branch information
chkob committed Sep 25, 2016
1 parent 0fd021c commit 8b2b2a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion cximage/CxImageDLL/CxImageCrtDll.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{771FDA7B-A299-4974-982D-8B77973C7896}</ProjectGuid>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
Expand Down
22 changes: 11 additions & 11 deletions cximage/ximapng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void CxImagePNG::ima_png_error(png_struct *png_ptr, char *message)
{
strcpy(info.szLastError,message);
//longjmp(png_ptr->png_jmpbuf, 1);
png_jmpbuf(png_ptr);
longjmp(png_jmpbuf(png_ptr), 1);
}
////////////////////////////////////////////////////////////////////////////////
#if CXIMAGE_SUPPORT_DECODE
Expand All @@ -38,9 +38,9 @@ void CxImagePNG::expand2to4bpp(uint8_t* prow)
////////////////////////////////////////////////////////////////////////////////
bool CxImagePNG::Decode(CxFile *hFile)
{
png_struct *png_ptr;
png_info *info_ptr;
uint8_t *row_pointers=NULL;
png_struct *png_ptr = nullptr;
png_info *info_ptr = nullptr;
uint8_t *row_pointers=nullptr;
CImageIterator iter(this);

cx_try
Expand All @@ -64,7 +64,7 @@ bool CxImagePNG::Decode(CxFile *hFile)
* the normal method of doing things with libpng). REQUIRED unless you
* set up your own error handlers in the png_create_read_struct() earlier. */
//if (setjmp(png_ptr->png_jmpbuf)) {
if(png_jmpbuf(png_ptr)){
if(setjmp(png_jmpbuf(png_ptr))){
/* Free all of the memory associated with the png_ptr and info_ptr */
delete [] row_pointers;
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
Expand All @@ -83,7 +83,7 @@ bool CxImagePNG::Decode(CxFile *hFile)
head.biHeight= info_ptr->height;
info.dwType = CXIMAGE_FORMAT_PNG;
//longjmp(png_ptr->png_jmpbuf, 1);
png_jmpbuf(png_ptr);
longjmp(png_jmpbuf(png_ptr), 1);
}

/* calculate new number of channels */
Expand All @@ -105,7 +105,7 @@ bool CxImagePNG::Decode(CxFile *hFile)
default:
strcpy(info.szLastError,"unknown PNG color type");
//longjmp(png_ptr->png_jmpbuf, 1);
png_jmpbuf(png_ptr);
longjmp(png_jmpbuf(png_ptr),1);
}

//find the right pixel depth used for cximage
Expand All @@ -116,7 +116,7 @@ bool CxImagePNG::Decode(CxFile *hFile)

if (!Create(info_ptr->width, info_ptr->height, pixel_depth, CXIMAGE_FORMAT_PNG)){
//longjmp(png_ptr->png_jmpbuf, 1);
png_jmpbuf(png_ptr);
longjmp(png_jmpbuf(png_ptr),1);
}

/* get metrics */
Expand Down Expand Up @@ -195,7 +195,7 @@ bool CxImagePNG::Decode(CxFile *hFile)

// <vho> - handle cancel
//if (info.nEscape) longjmp(png_ptr->png_jmpbuf, 1);
if(info.nEscape) png_jmpbuf(png_ptr);
if(info.nEscape) longjmp(png_jmpbuf(png_ptr),1);

// row_bytes is the width x number of channels x (bit-depth / 8)
row_pointers = new uint8_t[info_ptr->rowbytes + 8];
Expand All @@ -219,7 +219,7 @@ bool CxImagePNG::Decode(CxFile *hFile)

// <vho> - handle cancel
//if (info.nEscape) longjmp(png_ptr->png_jmpbuf, 1);
if(info.nEscape) png_jmpbuf(png_ptr);
if(info.nEscape) longjmp(png_jmpbuf(png_ptr),1);

#if CXIMAGE_SUPPORT_ALPHA // <vho>
if (AlphaIsValid()) {
Expand Down Expand Up @@ -352,7 +352,7 @@ bool CxImagePNG::Encode(CxFile *hFile)
* error hadnling functions in the png_create_write_struct() call.
*/
//if (setjmp(png_ptr->png_jmpbuf)){
if(png_jmpbuf(png_ptr)){
if(setjmp(png_jmpbuf(png_ptr))){
/* If we get here, we had a problem reading the file */
if (info_ptr->palette) free(info_ptr->palette);
png_destroy_write_struct(&png_ptr, (png_infopp)&info_ptr);
Expand Down
2 changes: 1 addition & 1 deletion cximage/ximapng.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class CxImagePNG : public CxImage
{
strncpy((char*)png_ptr->error_ptr, error_msg, 255);
//longjmp(png_ptr->png_jmpbuf, 1);
png_jmpbuf(png_ptr);
longjmp(png_jmpbuf(png_ptr),1);
}
};

Expand Down

0 comments on commit 8b2b2a5

Please sign in to comment.