Switched from <fstream.h> to <fstream> as per the warning the compiler gave me, and the C++ standard.
This commit is contained in:
parent
62019e0849
commit
5775a9be0e
1 changed files with 28 additions and 0 deletions
|
@ -25,6 +25,8 @@
|
|||
#include <string>
|
||||
#include <png.h>
|
||||
#include <jpeglib.h>
|
||||
#include <gif_lib.h>
|
||||
#include <fstream>
|
||||
#include "graphics.hpp"
|
||||
#include "image_util.hpp"
|
||||
#include "memory.hpp"
|
||||
|
@ -54,6 +56,10 @@ namespace mapnik
|
|||
{
|
||||
save_as_jpeg(filename,85,image);
|
||||
}
|
||||
else if (type=="gif")
|
||||
{
|
||||
save_as_gif(filename,image);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageUtils::save_as_png(const std::string& filename,const Image32& image)
|
||||
|
@ -151,4 +157,26 @@ namespace mapnik
|
|||
fclose(fp);
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
}
|
||||
|
||||
void ImageUtils::save_as_gif(const std::string& filename,const Image32& image)
|
||||
{
|
||||
GifFileType *fp=EGifOpenFileName(filename.c_str(),0);
|
||||
if (!fp) return;
|
||||
int width=image.width();
|
||||
int height=image.height();
|
||||
ColorMapObject *OutputColorMap = MakeMapObject(256, NULL);
|
||||
|
||||
EGifPutScreenDesc(fp, width, height, 8, 0, OutputColorMap);
|
||||
EGifPutImageDesc(fp, 0, 0, width, height, FALSE, NULL);
|
||||
|
||||
const ImageData32& imageData=image.data();
|
||||
|
||||
for (int i=0;i<height;i++)
|
||||
{
|
||||
EGifPutLine(fp, (GifPixelType*)imageData.getRow(i), width);
|
||||
}
|
||||
|
||||
EGifCloseFile(fp);
|
||||
FreeMapObject(OutputColorMap);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue