/[opencvs]/eyes/bitmap_to_hpgl2.c
ViewVC logotype

Contents of /eyes/bitmap_to_hpgl2.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Tue Apr 16 13:59:15 2013 UTC (5 years, 7 months ago) by hib
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
Added hpgl2 routines and bitmap_to_hpgl2 - this allows
us to use the vector mode to print out 600 dots per inch
on the hp designjet 600.  It is kind of a folloy, but it is a use of what I have versus what I dont have.
I only made a 36 x 1/2 inch strip so far.  This has no scaling defined so it
should be asolute.  the print area is about 3 inches smaller (or more) than the printer size. Also,  the printer margins is not even.  But hey,
it probably works.

Right now I am testing a 2.3 inch long strip which will take 20 minutes to run.
And then there is the question of if the plotter can handle millions
of vector commands - which we just don't know yet.
If it can't then there might be a way to send it in blocks - I guess blocks of 12 million or so because that is the memory size of the plotter I got.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <math.h>
4 #include <string.h>
5 #include <sys/resource.h>
6 #include <wand/MagickWand.h>
7
8
9 #include "uthash.h"
10 #include "hpgl2.h"
11
12
13
14
15 #define ThrowWandException(wand) \
16 { \
17 char \
18 *description; \
19 \
20 ExceptionType \
21 severity; \
22 \
23 description=MagickGetException(wand,&severity); \
24 (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \
25 description=(char *) MagickRelinquishMemory(description); \
26 exit(-1); \
27 }
28
29
30
31
32
33
34
35
36
37 int main(int argc,char **argv)
38 {
39 /* set the stack limit to 500 megabytes */
40 const rlim_t stacksize = 2000*1024*1024; // 2 gigabytes
41 struct rlimit rl;
42
43 char *iname=argv[1];
44
45 unsigned char *otherrand;
46 int other;
47 unsigned short *rbuf;
48 unsigned short *rbackbuf;
49 int number_of_points;
50 int number_second_points;
51 struct point *points_to_look_at;
52 struct point *second_points_to_look_at;
53 struct point *end_points_to_look_at;
54 struct point *temp_points;
55 int number_end_points;
56 PixelWand *c_wand = NULL;
57 PixelWand *c2_wand = NULL;
58
59 MagickWandGenesis();
60 ssize_t width,height;
61
62 if (!MagickSetResourceLimit(MemoryResource,2000000000)) {
63 fprintf(stderr,"couldnt set memory resource\n");
64 }
65 if (!MagickSetResourceLimit(AreaResource,2000000000)) {
66 fprintf(stderr,"couldnt set area resource\n");
67 }
68 if (!MagickSetResourceLimit(MapResource,2000000000)) {
69 fprintf(stderr,"couldnt set map resource\n");
70 }
71
72 MagickPixelPacket input_pixel;
73 MagickWand *input_wand = NULL;
74 input_wand =NewMagickWand();
75 MagickReadImage(input_wand,iname);
76 width = MagickGetImageWidth(input_wand);
77 height = MagickGetImageHeight(input_wand);
78
79
80 PixelIterator *iterator;
81 PixelWand **pixels;
82 c_wand = NewPixelWand();
83 PixelSetColor(c_wand,"black"); /* for now */
84
85
86 MagickBooleanType status;
87 PixelIterator *input_iterator;
88 PixelWand **input_pixels;
89 register ssize_t x;
90 ssize_t y;
91
92 input_iterator=NewPixelIterator(input_wand);
93 if ((input_iterator == (PixelIterator *) NULL) )
94 ThrowWandException(input_wand);
95
96
97 hpgl2_init();
98
99 for (y=0; y < (ssize_t) height; y++)
100 {
101 fprintf(stderr,".");
102 input_pixels=PixelGetNextIteratorRow(input_iterator,&width);
103
104 for (x=0; x < (ssize_t) width; x++)
105 {
106 PixelGetMagickColor(input_pixels[x],&input_pixel);
107 if (!(input_pixel.red)) {
108 hpgl2_point((int)(x),(int)(y));
109 }
110 } /* for each column */
111 }
112 fprintf(stderr,"\na");
113 //input_iterator=DestroyPixelIterator(input_iterator);
114
115 fprintf(stderr,"\nb");
116 hpgl2_finish();
117 fprintf(stderr,"\nc");
118 MagickWandTerminus();
119 return(0);
120 }

  ViewVC Help
Powered by ViewVC 1.1.5