mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 21:40:33 +05:00
Merge branch 'fix_jpeg' into 'master'
Fix build/image export with USE_JPEG=ON See merge request !63
This commit is contained in:
commit
9b0e13730f
@ -131,6 +131,7 @@ set_vars( NETGEN_CMAKE_ARGS
|
|||||||
USE_NATIVE_ARCH
|
USE_NATIVE_ARCH
|
||||||
USE_OCC
|
USE_OCC
|
||||||
USE_MPEG
|
USE_MPEG
|
||||||
|
USE_JPEG
|
||||||
USE_INTERNAL_TCL
|
USE_INTERNAL_TCL
|
||||||
INSTALL_PROFILES
|
INSTALL_PROFILES
|
||||||
INTEL_MIC
|
INTEL_MIC
|
||||||
|
60
ng/ngpkg.cpp
60
ng/ngpkg.cpp
@ -2007,7 +2007,9 @@ namespace netgen
|
|||||||
int w = Togl_Width (togl);
|
int w = Togl_Width (togl);
|
||||||
int h = Togl_Height (togl);
|
int h = Togl_Height (togl);
|
||||||
|
|
||||||
Array<char> buffer(w*h*3);
|
Array<unsigned char> buffer(w*h*3);
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
|
||||||
|
glPixelStorei(GL_PACK_ALIGNMENT,1);
|
||||||
glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, &buffer[0]);
|
glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, &buffer[0]);
|
||||||
|
|
||||||
#ifdef JPEGLIB
|
#ifdef JPEGLIB
|
||||||
@ -2052,20 +2054,17 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
#endif // JPEGLIB
|
#endif // JPEGLIB
|
||||||
{
|
{
|
||||||
char str[250];
|
string command;
|
||||||
char filename2[250];
|
string filename2;
|
||||||
int len = strlen(filename);
|
|
||||||
strcpy (filename2, filename);
|
|
||||||
|
|
||||||
filename2[len-3] = 'p';
|
filename2 = filename;
|
||||||
filename2[len-2] = 'p';
|
|
||||||
filename2[len-1] = 'm';
|
if(filename2.substr(len-3) != ".ppm")
|
||||||
filename2[len] = 0;
|
filename2 += ".ppm";
|
||||||
|
|
||||||
cout << "Snapshot to file '" << filename << endl;
|
cout << "Snapshot to file '" << filename << endl;
|
||||||
|
|
||||||
int w = Togl_Width (togl);
|
int w = Togl_Width (togl);
|
||||||
w = int((w + 1) / 4) * 4 + 4;
|
|
||||||
int h = Togl_Height (togl);
|
int h = Togl_Height (togl);
|
||||||
|
|
||||||
ofstream outfile(filename2);
|
ofstream outfile(filename2);
|
||||||
@ -2079,30 +2078,31 @@ namespace netgen
|
|||||||
outfile.put (buffer[k+3*j+3*w*(h-i-1)]);
|
outfile.put (buffer[k+3*j+3*w*(h-i-1)]);
|
||||||
outfile << flush;
|
outfile << flush;
|
||||||
|
|
||||||
// convert image file (Unix/Linux only):
|
if (filename2 == string(filename))
|
||||||
sprintf(str,"convert -quality 100 %s %s", filename2, filename);
|
return TCL_OK;
|
||||||
|
else
|
||||||
int err = system(str);
|
|
||||||
if (err != 0)
|
|
||||||
{
|
{
|
||||||
Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot convert image file", TCL_VOLATILE);
|
// convert image file (Unix/Linux only):
|
||||||
return TCL_ERROR;
|
command = string("convert -quality 100 ") + filename2 + " " + filename;
|
||||||
}
|
|
||||||
sprintf(str,"rm %s", filename2);
|
|
||||||
|
|
||||||
err = system(str);
|
int err = system(command.c_str());
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot delete temporary file", TCL_VOLATILE);
|
Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot convert image file, stored as .ppm", TCL_VOLATILE);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command = string("rm ") + filename2;
|
||||||
|
err = system(command.c_str());
|
||||||
|
|
||||||
|
if (err != 0)
|
||||||
|
{
|
||||||
|
Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot delete temporary file", TCL_VOLATILE);
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
cout << "Snapshot to " << filename << " not supported" << endl;
|
|
||||||
return TCL_ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user