Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15d1e43

Browse files
committed
More floating-point buffer progress
1 parent 83c5385 commit 15d1e43

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/_backend_agg.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ RendererAgg::RendererAgg(unsigned int width, unsigned int height, double dpi)
3939
rendererBase.clear(_fill_color);
4040
rendererAA.attach(rendererBase);
4141
rendererBin.attach(rendererBase);
42-
hatchRenderingBuffer.attach(hatchBuffer, HATCH_SIZE, HATCH_SIZE, HATCH_SIZE * 4);
42+
hatchRenderingBuffer.attach(
43+
hatchBuffer, HATCH_SIZE, HATCH_SIZE, HATCH_SIZE * sizeof(color_type));
4344
}
4445

4546
RendererAgg::~RendererAgg()
@@ -95,34 +96,37 @@ void RendererAgg::tostring_rgb(uint8_t *buf)
9596
agg::rendering_buffer renderingBufferTmp;
9697
renderingBufferTmp.attach(buf, width, height, row_len);
9798

98-
agg::color_conv(&renderingBufferTmp, &renderingBuffer, agg::color_conv_rgba32_to_rgb24());
99+
agg::convert<agg::pixfmt_rgb24, pixfmt, agg::rendering_buffer>(&renderingBufferTmp, &renderingBuffer);
99100
}
100101

101102
void RendererAgg::tostring_argb(uint8_t *buf)
102103
{
103104
//"Return the rendered buffer as an RGB string";
104105

105-
int row_len = width * 4;
106+
int row_len = width * sizeof(agg::rgba8);
106107

107108
agg::rendering_buffer renderingBufferTmp;
108109
renderingBufferTmp.attach(buf, width, height, row_len);
109-
agg::color_conv(&renderingBufferTmp, &renderingBuffer, agg::color_conv_rgba32_to_argb32());
110+
111+
agg::convert<agg::pixfmt_argb32, pixfmt, agg::rendering_buffer>(&renderingBufferTmp, &renderingBuffer);
110112
}
111113

112114
void RendererAgg::tostring_bgra(uint8_t *buf)
113115
{
114116
//"Return the rendered buffer as an RGB string";
115117

116-
int row_len = width * 4;
118+
int row_len = width * sizeof(agg::rgba8);
117119

118120
agg::rendering_buffer renderingBufferTmp;
119121
renderingBufferTmp.attach(buf, width, height, row_len);
120122

121-
agg::color_conv(&renderingBufferTmp, &renderingBuffer, agg::color_conv_rgba32_to_bgra32());
123+
agg::convert<agg::pixfmt_bgra32, pixfmt, agg::rendering_buffer>(&renderingBufferTmp, &renderingBuffer);
122124
}
123125

124126
agg::rect_i RendererAgg::get_content_extents()
125127
{
128+
// TODO: This is most definitely broken
129+
126130
agg::rect_i r(width, height, 0, 0);
127131

128132
// Looks at the alpha channel to find the minimum extents of the image

src/_backend_agg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "agg_image_accessors.h"
1616
#include "agg_pixfmt_amask_adaptor.h"
1717
#include "agg_pixfmt_gray.h"
18+
#include "agg_pixfmt_rgb.h"
1819
#include "agg_pixfmt_rgba.h"
1920
#include "agg_rasterizer_scanline_aa.h"
2021
#include "agg_renderer_base.h"
@@ -293,7 +294,7 @@ class RendererAgg
293294
agg::trans_affine lastclippath_transform;
294295

295296
static const size_t HATCH_SIZE = 72;
296-
agg::int8u hatchBuffer[HATCH_SIZE * HATCH_SIZE * 4];
297+
agg::int8u hatchBuffer[HATCH_SIZE * HATCH_SIZE * sizeof(color_type)];
297298
agg::rendering_buffer hatchRenderingBuffer;
298299

299300
agg::rgba _fill_color;

0 commit comments

Comments
 (0)