134
134
/* ----------------------------------------------------------------------- */
135
135
/* Color operations */
136
136
/* ----------------------------------------------------------------------- */
137
- (void) DPSsetalpha: (float)a
137
- (void) DPSsetalpha: (CGFloat)a
139
139
[super DPSsetalpha: a];
140
140
/* This needs to be defined base on the the language level, etc. in
143
143
fprintf(gstream, "GSsetalpha\n");
146
- (void) DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k
146
- (void) DPSsetcmykcolor: (CGFloat)c : (CGFloat)m : (CGFloat)y : (CGFloat)k
148
148
[super DPSsetcmykcolor: c : m : y : k];
149
149
fpfloat(gstream, c);
153
153
fprintf(gstream, "setcmykcolor\n");
156
- (void) DPSsetgray: (float)gray
156
- (void) DPSsetgray: (CGFloat)gray
158
158
[super DPSsetgray: gray];
159
159
fpfloat(gstream, gray);
160
160
fprintf(gstream, "setgray\n");
163
- (void) DPSsethsbcolor: (float)h : (float)s : (float)b
163
- (void) DPSsethsbcolor: (CGFloat)h : (CGFloat)s : (CGFloat)b
165
165
[super DPSsethsbcolor: h : s : b];
166
166
fpfloat(gstream, h);
169
169
fprintf(gstream, "sethsbcolor\n");
172
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b
172
- (void) DPSsetrgbcolor: (CGFloat)r : (CGFloat)g : (CGFloat)b
174
174
[super DPSsetrgbcolor: r : g : b];
175
175
fpfloat(gstream, r);
196
196
/* ----------------------------------------------------------------------- */
197
197
/* Text operations */
198
198
/* ----------------------------------------------------------------------- */
199
- (void) DPSashow: (float)x : (float)y : (const char*)s
199
- (void) DPSashow: (CGFloat)x : (CGFloat)y : (const char*)s
201
201
fpfloat(gstream, x);
202
202
fpfloat(gstream, y);
240
240
fprintf(gstream, ") widthshow\n");
243
- (void) DPSxshow: (const char*)s : (const float*)numarray : (int)size
245
[self notImplemented: _cmd];
248
- (void) DPSxyshow: (const char*)s : (const float*)numarray : (int)size
250
[self notImplemented: _cmd];
253
- (void) DPSyshow: (const char*)s : (const float*)numarray : (int)size
255
[self notImplemented: _cmd];
259
- (void) GSSetCharacterSpacing: (float)extra
243
- (void) DPSxshow: (const char*)s : (const CGFloat*)numarray : (int)size
245
[self notImplemented: _cmd];
248
- (void) DPSxyshow: (const char*)s : (const CGFloat*)numarray : (int)size
250
[self notImplemented: _cmd];
253
- (void) DPSyshow: (const char*)s : (const CGFloat*)numarray : (int)size
255
[self notImplemented: _cmd];
259
- (void) GSSetCharacterSpacing: (CGFloat)extra
261
261
[self notImplemented: _cmd];
322
- (void) GSShowGlyphsWithAdvances: (const NSGlyph *)glyphs
323
: (const NSSize *)advances
326
// FIXME: Currently advances is ignored
327
[self GSShowGlyphs: glyphs : length];
323
331
/* ----------------------------------------------------------------------- */
324
332
/* Gstate Handling */
371
379
/* ----------------------------------------------------------------------- */
372
380
/* Gstate operations */
373
381
/* ----------------------------------------------------------------------- */
374
- (void) DPSsetdash: (const float*)pat : (int)size : (float)offset
382
- (void) DPSsetdash: (const CGFloat*)pat : (NSInteger)size : (CGFloat)offset
377
385
fprintf(gstream, "[");
382
390
fprintf(gstream, "setdash\n");
385
- (void) DPSsetflat: (float)flatness
393
- (void) DPSsetflat: (CGFloat)flatness
387
395
[super DPSsetflat: flatness];
388
396
fpfloat(gstream, flatness);
389
397
fprintf(gstream, "setflat\n");
392
- (void) DPSsethalftonephase: (float)x : (float)y
400
- (void) DPSsethalftonephase: (CGFloat)x : (CGFloat)y
394
402
[super DPSsethalftonephase: x : y];
395
403
fpfloat(gstream, x);
409
417
fprintf(gstream, "%d setlinejoin\n", linejoin);
412
- (void) DPSsetlinewidth: (float)width
420
- (void) DPSsetlinewidth: (CGFloat)width
414
422
[super DPSsetlinewidth: width];
415
423
fpfloat(gstream, width);
416
424
fprintf(gstream, "setlinewidth\n");
419
- (void) DPSsetmiterlimit: (float)limit
427
- (void) DPSsetmiterlimit: (CGFloat)limit
421
429
[super DPSsetmiterlimit: limit];
422
430
fpfloat(gstream, limit);
433
441
/* ----------------------------------------------------------------------- */
434
442
/* Matrix operations */
435
443
/* ----------------------------------------------------------------------- */
436
- (void) DPSconcat: (const float*)m
444
- (void) DPSconcat: (const CGFloat*)m
438
446
[super DPSconcat: m];
466
474
fprintf(gstream, "initmatrix\n");
469
- (void) DPSrotate: (float)angle
477
- (void) DPSrotate: (CGFloat)angle
471
479
[super DPSrotate: angle];
472
480
fpfloat(gstream, angle);
473
481
fprintf(gstream, "rotate\n");
476
- (void) DPSscale: (float)x : (float)y
484
- (void) DPSscale: (CGFloat)x : (CGFloat)y
478
486
[super DPSscale: x : y];
479
487
fpfloat(gstream, x);
481
489
fprintf(gstream, "scale\n");
484
- (void) DPStranslate: (float)x : (float)y
492
- (void) DPStranslate: (CGFloat)x : (CGFloat)y
486
494
[super DPStranslate: x : y];
487
495
fpfloat(gstream, x);
521
529
/* ----------------------------------------------------------------------- */
522
530
/* Paint operations */
523
531
/* ----------------------------------------------------------------------- */
524
- (void) DPSarc: (float)x : (float)y : (float)r : (float)angle1 : (float)angle2
532
- (void) DPSarc: (CGFloat)x : (CGFloat)y : (CGFloat)r : (CGFloat)angle1 : (CGFloat)angle2
526
534
fpfloat(gstream, x);
527
535
fpfloat(gstream, y);
561
569
fprintf(gstream, "closepath\n");
564
- (void)DPScurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2
565
: (float)x3 : (float)y3
572
- (void)DPScurveto: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2
573
: (CGFloat)x3 : (CGFloat)y3
567
575
fpfloat(gstream, x1);
568
576
fpfloat(gstream, y1);
598
606
fprintf(gstream, "initclip\n");
601
- (void) DPSlineto: (float)x : (float)y
609
- (void) DPSlineto: (CGFloat)x : (CGFloat)y
603
611
fpfloat(gstream, x);
604
612
fpfloat(gstream, y);
605
613
fprintf(gstream, "lineto\n");
608
- (void) DPSmoveto: (float)x : (float)y
616
- (void) DPSmoveto: (CGFloat)x : (CGFloat)y
610
618
fpfloat(gstream, x);
611
619
fpfloat(gstream, y);
617
625
fprintf(gstream, "newpath\n");
620
- (void) DPSpathbbox: (float*)llx : (float*)lly : (float*)urx : (float*)ury
628
- (void) DPSpathbbox: (CGFloat*)llx : (CGFloat*)lly : (CGFloat*)urx : (CGFloat*)ury
624
- (void) DPSrcurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2
625
: (float)x3 : (float)y3
632
- (void) DPSrcurveto: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2
633
: (CGFloat)x3 : (CGFloat)y3
627
635
fpfloat(gstream, x1);
628
636
fpfloat(gstream, y1);
665
673
fprintf(gstream, "reversepath\n");
668
- (void) DPSrlineto: (float)x : (float)y
676
- (void) DPSrlineto: (CGFloat)x : (CGFloat)y
670
678
fpfloat(gstream, x);
671
679
fpfloat(gstream, y);
672
680
fprintf(gstream, "rlineto\n");
675
- (void) DPSrmoveto: (float)x : (float)y
683
- (void) DPSrmoveto: (CGFloat)x : (CGFloat)y
677
685
fpfloat(gstream, x);
678
686
fpfloat(gstream, y);
784
792
/*-------------------------------------------------------------------------*/
785
793
/* Graphics Extensions Ops */
786
794
/*-------------------------------------------------------------------------*/
787
- (void) DPScomposite: (float)x : (float)y : (float)w : (float)h
788
: (int)gstateNum : (float)dx : (float)dy : (int)op
795
- (void) DPScomposite: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
796
: (NSInteger)gstateNum : (CGFloat)dx : (CGFloat)dy : (NSCompositingOperation)op
790
798
fpfloat(gstream, x);
791
799
fpfloat(gstream, y);
792
800
fpfloat(gstream, w);
793
801
fpfloat(gstream, h);
794
fprintf(gstream, "%d ", gstateNum);
802
fprintf(gstream, "%d ", (int)gstateNum);
795
803
fpfloat(gstream, dx);
796
804
fpfloat(gstream, dy);
797
fprintf(gstream, "%d composite\n", op);
805
fprintf(gstream, "%d composite\n", (int)op);
800
- (void) DPScompositerect: (float)x : (float)y : (float)w : (float)h : (int)op
808
- (void) DPScompositerect: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h : (NSCompositingOperation)op
802
810
fpfloat(gstream, x);
803
811
fpfloat(gstream, y);
804
812
fpfloat(gstream, w);
805
813
fpfloat(gstream, h);
806
fprintf(gstream, "%d compositerect\n", op);
814
fprintf(gstream, "%d compositerect\n", (int)op);
809
- (void) DPSdissolve: (float)x : (float)y : (float)w : (float)h
810
: (int)gstateNum : (float)dx : (float)dy : (float)delta
817
- (void) DPSdissolve: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
818
: (NSInteger)gstateNum : (CGFloat)dx : (CGFloat)dy : (CGFloat)delta
812
820
NSLog(@"DPSinvalidcontext: dissolve in a stream context");
815
- (void) GScomposite: (int)gstateNum
823
- (void) GScomposite: (NSInteger)gstateNum
816
824
toPoint: (NSPoint)aPoint
817
825
fromRect: (NSRect)srcRect
818
826
operation: (NSCompositingOperation)op
819
fraction: (float)delta
827
fraction: (CGFloat)delta
821
829
[self DPScomposite: NSMinX(srcRect) : NSMinY(srcRect) : NSWidth(srcRect) : NSHeight(srcRect)
822
830
: gstateNum : aPoint.x : aPoint.y : op];
881
889
@implementation GSStreamContext (Graphics)
883
- (void) NSDrawBitmap: (NSRect)rect : (int)pixelsWide : (int)pixelsHigh
884
: (int)bitsPerSample : (int)samplesPerPixel
885
: (int)bitsPerPixel : (int)bytesPerRow : (BOOL)isPlanar
891
- (void) NSDrawBitmap: (NSRect)rect : (NSInteger)pixelsWide : (NSInteger)pixelsHigh
892
: (NSInteger)bitsPerSample : (NSInteger)samplesPerPixel
893
: (NSInteger)bitsPerPixel : (NSInteger)bytesPerRow : (BOOL)isPlanar
886
894
: (BOOL)hasAlpha : (NSString *)colorSpaceName
887
895
: (const unsigned char *const [5])data
897
NSInteger bytes, spp;
891
899
BOOL flipped = NO;
893
901
/* In a flipped view, we don't want to flip the image again, which would
913
921
(bitsPerSample * pixelsWide * pixelsHigh + 7) / 8;
914
922
if (bytes * samplesPerPixel != bytesPerRow * pixelsHigh)
916
NSLog(@"Image Rendering Error: Dodgy bytesPerRow value %d", bytesPerRow);
924
NSLog(@"Image Rendering Error: Dodgy bytesPerRow value %d", (int)bytesPerRow);
917
925
NSLog(@" pixelsHigh=%d, bytes=%d, samplesPerPixel=%d",
918
bytesPerRow, pixelsHigh, bytes);
926
(int)bytesPerRow, (int)pixelsHigh, (int)bytes);
936
944
fprintf(gstream, "%d %d %d [%d 0 0 %d 0 %d]\n",
937
pixelsWide, pixelsHigh, bitsPerSample, pixelsWide,
938
(flipped) ? pixelsHigh : -pixelsHigh, pixelsHigh);
945
(int)pixelsWide, (int)pixelsHigh, (int)bitsPerSample, (int)pixelsWide,
946
(flipped) ? (int)pixelsHigh : (int)-pixelsHigh, (int)pixelsHigh);
939
947
fprintf(gstream, "{currentfile %d string readhexstring pop}\n",
941
fprintf(gstream, "false %d colorimage\n", spp);
948
(int)(pixelsWide * spp));
949
fprintf(gstream, "false %d colorimage\n", (int)spp);
945
953
fprintf(gstream, "%d %d %d [%d 0 0 %d 0 %d]\n",
946
pixelsWide, pixelsHigh, bitsPerSample, pixelsWide,
947
(flipped) ? pixelsHigh : -pixelsHigh, pixelsHigh);
954
(int)pixelsWide, (int)pixelsHigh, (int)bitsPerSample, (int)pixelsWide,
955
(flipped) ? (int)pixelsHigh : (int)-pixelsHigh, (int)pixelsHigh);
948
956
fprintf(gstream, "currentfile image\n");