Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/raggPublic

Commitf606c63

Browse files
committed
report more info in agg_capture
1 parentc7c6010 commitf606c63

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

‎NEWS.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Fix support for the default symbol font on many linux distros
44
(StandardSymbolPS) by ensuring proper fallback during character metric
55
calculation (#136,#201)
6+
*`agg_capture()` now reports the current "page number" as well as whether any
7+
drawing has occured since the last time the capture was taken as attributes
8+
in the return value (but only if you request native raster) (#204)
69

710
#ragg 1.5.0
811

‎src/AggDevice.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class AggDevice {
6969
unsignedchar* buffer;
7070

7171
int pageno;
72+
bool changed;
7273
std::string file;
7374
R_COLOR background;
7475
int background_int;
@@ -356,6 +357,7 @@ class AggDevice {
356357
if (evenodd) ras.filling_rule(agg::fill_even_odd);
357358

358359
if (recording_mask ==NULL && recording_raster ==NULL) {
360+
changed =true;
359361
solid_renderer.color(convertColour(fill));
360362
if (current_mask ==NULL) {
361363
render<agg::scanline_p8>(ras, ras_clip, slp, solid_renderer, current_clip !=NULL);
@@ -411,6 +413,7 @@ class AggDevice {
411413
agg::scanline_u8 slu;
412414
setStroke(ras, path, lty, lwd, lend, ljoin, lmitre);
413415
if (recording_mask ==NULL && recording_raster ==NULL) {
416+
changed =true;
414417
solid_renderer.color(convertColour(col));
415418
if (current_mask ==NULL) {
416419
render<agg::scanline_u8>(ras, ras_clip, slu, solid_renderer, current_clip !=NULL);
@@ -537,6 +540,7 @@ void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::newPage(unsigned int bg) {
537540
renderer.clear(background);
538541
}
539542
pageno++;
543+
changed =true;
540544
}
541545
template<classPIXFMT,classR_COLOR,typename BLNDFMT>
542546
void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::close() {
@@ -1044,6 +1048,7 @@ void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::useGroup(SEXP ref, SEXP trans) {
10441048

10451049
agg::scanline_u8 sl;
10461050
if (recording_mask ==NULL && recording_raster ==NULL) {
1051+
changed =true;
10471052
if (current_mask ==NULL) {
10481053
it->second->draw(mtx, ras, ras_clip, sl, renderer, clip);
10491054
}else {
@@ -1366,6 +1371,7 @@ void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::drawRaster(unsigned int *raster, int w
13661371

13671372
agg::scanline_u8 slu;
13681373
if (recording_mask ==NULL && recording_raster ==NULL) {
1374+
changed =true;
13691375
if (current_mask ==NULL) {
13701376
render_raster<pixfmt_r_raster, BLNDFMT>(rbuf, w, h, ras, ras_clip, slu, interpolator, renderer, interpolate, current_clip !=NULL,false);
13711377
}else {
@@ -1446,6 +1452,7 @@ void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::drawText(double x, double y, const cha
14461452

14471453
agg::scanline_u8 slu;
14481454
if (recording_mask ==NULL && recording_raster ==NULL) {
1455+
changed =true;
14491456
solid_renderer.color(convertColour(col));
14501457
if (current_mask ==NULL) {
14511458
t_ren.templateplot_text<BLNDFMT>(x, y, str, rot, hadj, solid_renderer, renderer, slu, device_id, ras_clip, current_clip !=NULL, recording_path);
@@ -1535,6 +1542,7 @@ void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::drawGlyph(int n, int *glyphs,
15351542

15361543
agg::scanline_u8 slu;
15371544
if (recording_mask ==NULL && recording_raster ==NULL) {
1545+
changed =true;
15381546
solid_renderer.color(convertColour(colour));
15391547
if (current_mask ==NULL) {
15401548
t_ren.templateplot_glyphs<BLNDFMT>(n, glyphs, x, y, rot, solid_renderer, renderer, slu, ras_clip, current_clip !=NULL, recording_path);

‎src/AggDeviceCapture.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#pragma once
22

3+
#include"Rinternals.h"
34
#include"ragg.h"
45
#include"AggDevice.h"
56

67
template<classPIXFMT>
78
classAggDeviceCapture :publicAggDevice<PIXFMT> {
89
public:
910
bool can_capture =true;
10-
11+
1112
AggDeviceCapture(constchar* fp,int w,int h,double ps,int bg,double res,
1213
double scaling,bool snap) :
1314
AggDevice<PIXFMT>(fp, w, h, ps, bg, res, scaling, snap)
1415
{
15-
16+
1617
}
1718
// Behaviour
1819
boolsavePage() {
@@ -27,6 +28,9 @@ class AggDeviceCapture : public AggDevice<PIXFMT> {
2728
INTEGER(dims)[0] =this->height;
2829
INTEGER(dims)[1] =this->width;
2930
Rf_setAttrib(raster, R_DimSymbol, dims);
31+
Rf_setAttrib(raster,Rf_mkString("page"),Rf_ScalarInteger(this->pageno));
32+
Rf_setAttrib(raster,Rf_mkString("changed"),Rf_ScalarLogical(this->changed));
33+
this->changed =false;
3034
UNPROTECT(2);
3135
return raster;
3236
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp