mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
RichText: JPG raw image data is now exported to PDF as JPEG
git-svn-id: svn://ultimatepp.org/upp/trunk@15834 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
be2bec3b02
commit
5da70205df
7 changed files with 42 additions and 11 deletions
|
|
@ -496,9 +496,7 @@ void ArrayCtrl::Set0(int i, int ii, const Value& v) {
|
|||
}
|
||||
|
||||
void ArrayCtrl::Set(int i, const Vector<Value>& v) {
|
||||
RTIMING("Set0");
|
||||
array.At(i).line.Clear();
|
||||
RTIMING("Set1");
|
||||
for(int ii = 0; ii < v.GetCount(); ii++)
|
||||
Set0(i, ii, v[ii]);
|
||||
AfterSet(i);
|
||||
|
|
@ -507,8 +505,6 @@ void ArrayCtrl::Set(int i, const Vector<Value>& v) {
|
|||
}
|
||||
|
||||
void ArrayCtrl::Set(int i, Vector<Value>&& v) {
|
||||
RTIMING("Set0");
|
||||
RTIMING("Set1");
|
||||
Vector<Value>& line = array.At(i).line;
|
||||
if(hasctrls || i == cursor) {
|
||||
line.Clear();
|
||||
|
|
@ -524,7 +520,6 @@ void ArrayCtrl::Set(int i, Vector<Value>&& v) {
|
|||
|
||||
void ArrayCtrl::AfterSet(int i)
|
||||
{
|
||||
RTIMING("AfterSet");
|
||||
SetSb();
|
||||
Refresh();
|
||||
SyncInfo();
|
||||
|
|
|
|||
|
|
@ -954,9 +954,15 @@ void DrawXPButton(Draw& w, Rect r, int type);
|
|||
struct PdfSignatureInfo;
|
||||
typedef String (*DrawingToPdfFnType)(const Array<Drawing>& report, Size pagesize, int margin,
|
||||
bool pdfa, const PdfSignatureInfo *sign);
|
||||
typedef void (*PdfDrawJPEGFnType)(Draw& w, int x, int y, int cx, int cy, const String& jpeg_data);
|
||||
|
||||
void SetDrawingToPdfFn(DrawingToPdfFnType Pdf);
|
||||
void SetDrawingToPdfFn(DrawingToPdfFnType Pdf, PdfDrawJPEGFnType Jpeg);
|
||||
DrawingToPdfFnType GetDrawingToPdfFn();
|
||||
PdfDrawJPEGFnType GetPdfDrawJPEGFn();
|
||||
|
||||
typedef bool (*IsJPGFnType)(StreamRaster *s);
|
||||
void SetIsJPGFn(IsJPGFnType isjpg);
|
||||
IsJPGFnType GetIsJPGFn();
|
||||
|
||||
#include "Display.h"
|
||||
#include "Cham.h"
|
||||
|
|
|
|||
|
|
@ -581,10 +581,12 @@ void DrawXPButton(Draw& w, Rect r, int type)
|
|||
}
|
||||
|
||||
static DrawingToPdfFnType sPdf;
|
||||
static PdfDrawJPEGFnType sJpeg;
|
||||
|
||||
void SetDrawingToPdfFn(DrawingToPdfFnType Pdf)
|
||||
void SetDrawingToPdfFn(DrawingToPdfFnType Pdf, PdfDrawJPEGFnType Jpeg)
|
||||
{
|
||||
sPdf = Pdf;
|
||||
sJpeg = Jpeg;
|
||||
}
|
||||
|
||||
DrawingToPdfFnType GetDrawingToPdfFn()
|
||||
|
|
@ -592,6 +594,23 @@ DrawingToPdfFnType GetDrawingToPdfFn()
|
|||
return sPdf;
|
||||
}
|
||||
|
||||
PdfDrawJPEGFnType GetPdfDrawJPEGFn()
|
||||
{
|
||||
return sJpeg;
|
||||
}
|
||||
|
||||
static IsJPGFnType sIsJPG;
|
||||
|
||||
void SetIsJPGFn(IsJPGFnType isjpg)
|
||||
{
|
||||
sIsJPG = isjpg;
|
||||
}
|
||||
|
||||
IsJPGFnType GetIsJPGFn()
|
||||
{
|
||||
return sIsJPG;
|
||||
}
|
||||
|
||||
Image (*render_glyph)(int cx, int x, Font font, int chr, int py, int pcy);
|
||||
|
||||
Image RenderGlyph(int cx, int x, Font font, int chr, int py, int pcy)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ String Pdf(const Array<Drawing>& report, Size sz, int margin, bool pdfa,
|
|||
|
||||
INITIALIZER(PdfDraw)
|
||||
{
|
||||
SetDrawingToPdfFn(Pdf);
|
||||
SetDrawingToPdfFn(Pdf, DrawJPEG);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,17 +241,20 @@ void RichRawImage::Paint(const Value& data, Draw& w, Size sz, void *) const
|
|||
One<StreamRaster> r = StreamRaster::OpenAny(ss);
|
||||
if(r) {
|
||||
Size isz = r->GetSize();
|
||||
if(GetIsJPGFn() && GetIsJPGFn()(~r) && GetPdfDrawJPEGFn())
|
||||
GetPdfDrawJPEGFn()(w, 0, 0, sz.cx, sz.cy, data);
|
||||
else
|
||||
if(isz.cx * isz.cy > sz.cx * sz.cy) { // conserve memory by scaling down from source
|
||||
ImageEncoder m;
|
||||
Rescale(m, sz, *r, r->GetSize());
|
||||
Rescale(m, sz, *r, isz);
|
||||
w.DrawImage(0, 0, sz.cx, sz.cy, m);
|
||||
}
|
||||
else
|
||||
w.DrawImage(0, 0, sz.cx, sz.cy, r->GetImage()); // scale up by Draw to give e.g. PDF chance to store unscaled
|
||||
}
|
||||
else
|
||||
if(IsString(data) && IsSVG(~data))
|
||||
w.DrawImage(0, 0, RenderSVGImage(sz, ~data));
|
||||
if(IsSVG(s))
|
||||
w.DrawImage(0, 0, RenderSVGImage(sz, s));
|
||||
}
|
||||
|
||||
Image RichRawImage::ToImage(int64 serial_id, const Value& data, Size sz, void *) const
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ public:
|
|||
Image GetExifThumbnail();
|
||||
};
|
||||
|
||||
bool IsJPG(StreamRaster *s);
|
||||
|
||||
class JPGEncoder : public StreamRasterEncoder {
|
||||
class Data;
|
||||
One<Data> data;
|
||||
|
|
|
|||
|
|
@ -712,9 +712,15 @@ Image JPGRaster::GetExifThumbnail()
|
|||
return StreamRaster::LoadStringAny(ss);
|
||||
}
|
||||
|
||||
bool IsJPG(StreamRaster *s)
|
||||
{
|
||||
return dynamic_cast<JPGRaster *>(s);
|
||||
}
|
||||
|
||||
INITIALIZER(JPGRaster)
|
||||
{
|
||||
StreamRaster::Register<JPGRaster>();
|
||||
SetIsJPGFn(IsJPG);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue