Skip to content

Commit

Permalink
fixed output size
Browse files Browse the repository at this point in the history
  • Loading branch information
kallaballa committed Jan 30, 2011
1 parent ceab1e5 commit 7a727db
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/raster/PclEncoder.cpp
Expand Up @@ -41,8 +41,10 @@ void PclEncoder::encode(Raster* raster, ostream& out) {
out << format(R_SPEED) % lconf->raster_speed;

out << PCL_UNKNOWN_BLAFOO3;
out << format(R_HEIGHT) % ((lconf->height * lconf->resolution) / POINTS_PER_INCH);
out << format(R_WIDTH) % ((lconf->width * lconf->resolution) / POINTS_PER_INCH);
out << format(R_HEIGHT) % ((lconf->height * lconf->resolution)
/ POINTS_PER_INCH);
out << format(R_WIDTH) % ((lconf->width * lconf->resolution)
/ POINTS_PER_INCH);
// Raster compression
int compressionLevel = 2;
if (lconf->raster_mode == 'c' || lconf->raster_mode == 'g')
Expand Down Expand Up @@ -83,14 +85,15 @@ void PclEncoder::encodeTile(Image* tile, ostream& out) {
for (y = height - 1; y >= 0; y--) {
int l;

// read scanline from right to left
// read scanline from left to right
for (int x = 0; x < width; x++) {
tile->readPixel(x, y, p);
buf[x] = p.pclValue(power_scale);
}

// find left/right of data (dir==0 ? left : right)
for (l = 0; l < width && !buf[l]; l++) {}
for (l = 0; l < width && !buf[l]; l++) {
}

if (l < width) {
// a line to print
Expand All @@ -101,10 +104,12 @@ void PclEncoder::encodeTile(Image* tile, ostream& out) {
for (r = width - 1; r > l && !buf[r]; r--) {
}
r++;

out << format(PCL_POS_Y) % (tile->offsetY() + lconf->basey + y);
out << format(PCL_POS_X) % (tile->offsetX() + lconf->basex + l);

if (dir) {
//reverse scan line
out << format(R_ROW_PIXELS) % (-(r - l));
for (n = 0; n < (r - l) / 2; n++) {
char t = buf[l + n];
Expand All @@ -119,6 +124,7 @@ void PclEncoder::encodeTile(Image* tile, ostream& out) {
n = 0;
while (l < r) {
int p;
// find run length
for (p = l; p < r && p < l + 128 && buf[p] == buf[l]; p++) {
;
}
Expand All @@ -141,9 +147,11 @@ void PclEncoder::encodeTile(Image* tile, ostream& out) {
}

out << format(R_ROW_BYTES) % ((n + 7) / 8 * 8);
while (r < n) {
out << pack[r++];

for (int i = 0; i < n; i++) {
out << pack[i];
}

while (r & 7) {
r++;
out << "\x80";
Expand Down

0 comments on commit 7a727db

Please sign in to comment.