1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-09-19 21:50:08 +00:00
pdf2htmlEX/src/HTMLRenderer/image.cc

66 lines
1.6 KiB
C++
Raw Normal View History

2012-08-14 08:23:15 +00:00
/*
* image.cc
*
* Handling images
*
* by WangLu
* 2012.08.14
*/
#include "HTMLRenderer.h"
2012-11-29 09:28:05 +00:00
#include "util/namespace.h"
2012-08-14 08:23:15 +00:00
2012-09-12 15:26:14 +00:00
namespace pdf2htmlEX {
2012-08-14 08:23:15 +00:00
void HTMLRenderer::drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, GBool interpolate, int *maskColors, GBool inlineImg)
{
2012-08-16 18:09:19 +00:00
return OutputDev::drawImage(state,ref,str,width,height,colorMap,interpolate,maskColors,inlineImg);
#if 0
2012-08-14 08:23:15 +00:00
if(maskColors)
return;
2012-08-14 09:50:16 +00:00
rgb8_image_t img(width, height);
2012-08-14 08:23:15 +00:00
auto imgview = view(img);
auto loc = imgview.xy_at(0,0);
ImageStream * img_stream = new ImageStream(str, width, colorMap->getNumPixelComps(), colorMap->getBits());
img_stream->reset();
for(int i = 0; i < height; ++i)
{
auto p = img_stream->getLine();
for(int j = 0; j < width; ++j)
{
GfxRGB rgb;
colorMap->getRGB(p, &rgb);
2012-08-14 09:50:16 +00:00
*loc = rgb8_pixel_t(colToByte(rgb.r), colToByte(rgb.g), colToByte(rgb.b));
2012-08-14 08:23:15 +00:00
p += colorMap->getNumPixelComps();
++ loc.x();
}
loc = imgview.xy_at(0, i+1);
}
2012-08-14 09:50:16 +00:00
png_write_view((format("i%|1$x|.png")%image_count).str(), imgview);
2012-08-14 08:23:15 +00:00
img_stream->close();
delete img_stream;
close_line();
2012-08-14 08:23:15 +00:00
double ctm[6];
memcpy(ctm, state->getCTM(), sizeof(ctm));
2012-08-14 08:23:15 +00:00
ctm[4] = ctm[5] = 0.0;
2012-08-14 09:50:16 +00:00
html_fout << format("<img class=\"i t%2%\" style=\"left:%3%px;bottom:%4%px;width:%5%px;height:%6%px;\" src=\"i%|1$x|.png\" />") % image_count % install_transform_matrix(ctm) % state->getCurX() % state->getCurY() % width % height << endl;
2012-08-14 08:23:15 +00:00
++ image_count;
2012-08-16 18:09:19 +00:00
#endif
2012-08-14 08:23:15 +00:00
}
2012-09-12 15:26:14 +00:00
} // namespace pdf2htmlEX