Main Page
Classes
Files
File List
File Members
include
common
postscript_utils.h
Go to the documentation of this file.
1
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
2
All rights reserved.
3
4
This software was developed in the APRIL Robotics Lab under the
5
direction of Edwin Olson, ebolson@umich.edu. This software may be
6
available under alternative licensing terms; contact the address above.
7
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions are met:
10
11
1. Redistributions of source code must retain the above copyright notice, this
12
list of conditions and the following disclaimer.
13
2. Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
The views and conclusions contained in the software and documentation are those
29
of the authors and should not be interpreted as representing official policies,
30
either expressed or implied, of the Regents of The University of Michigan.
31
*/
32
33
#ifndef _POSTSCRIPT_UTILS_H
34
#define _POSTSCRIPT_UTILS_H
35
36
// write commands in postscript language to render an image in the current
37
// graphics environment. The image will be rendered in one pixel per unit
38
// with Y up coordinate axis (e.g. upside down).
39
static
void
postscript_image
(FILE *f,
image_u8_t
*im)
40
{
41
// fprintf(f, "/readstring {\n currentfile exch readhexstring pop\n} bind def\n");
42
fprintf(f,
"/picstr %d string def\n"
, im->
width
);
43
44
fprintf(f,
"%d %d 8 [1 0 0 1 0 0]\n"
,
45
im->
width
, im->
height
);
46
47
fprintf(f,
"{currentfile picstr readhexstring pop}\nimage\n"
);
48
49
for
(
int
y = 0; y < im->
height
; y++) {
50
for
(
int
x = 0; x < im->
width
; x++) {
51
uint8_t v = im->
buf
[y*im->
stride
+ x];
52
fprintf(f,
"%02x"
, v);
53
if
((x % 32)==31)
54
fprintf(f,
"\n"
);
55
}
56
}
57
58
fprintf(f,
"\n"
);
59
}
60
61
#endif
image_u8::height
const int32_t height
Definition:
image_types.h:14
image_u8::width
const int32_t width
Definition:
image_types.h:13
image_u8::stride
const int32_t stride
Definition:
image_types.h:15
image_u8
Definition:
image_types.h:11
image_u8::buf
uint8_t * buf
Definition:
image_types.h:17
postscript_image
static void postscript_image(FILE *f, image_u8_t *im)
Definition:
postscript_utils.h:39
apriltags2
Author(s): Danylo Malyuta
autogenerated on Fri Oct 19 2018 04:02:32