1 // ----------------------------------------------------------------------------
2 // MODULE : FPXBaselineView
3 // LANGUAGE : C++
4 // CREATOR : Philippe BOSSUT
5 // CREAT. DATE : Friday, April 5, 1996
6 // DESCRIPTION :
7 // COMMENTS :
8 // SCCSID : @(#)fpxlib.cpp 1.3 08:41:22 29 Jan 1997
9 // ----------------------------------------------------------------------------
10 // Copyright (c) 1999 Digital Imaging Group, Inc.
11 // For conditions of distribution and use, see copyright notice
12 // in Flashpix.h
13 // ----------------------------------------------------------------------------
14
15 // ----------------------------------------------------------------------------
16
17 // Includes
18 // --------
19
20 #ifndef PageIVUE_h
21 #include "ri_page.h"
22 #endif
23
24 #ifndef OLECommun_h
25 #include "olecomm.h"
26 #endif
27 #ifndef OLECore_h
28 #include "olecore.h"
29 #endif
30 #ifndef OLEProperties_h
31 #include "oleprop.h"
32 #endif
33
34 #ifndef FileFlashPixIO_h
35 #include "f_fpxio.h"
36 #endif
37 #ifndef FileFlashPixView_h
38 #include "f_fpxvw.h"
39 #endif
40 #ifndef FPXImageView_h
41 #include "fpximgvw.h"
42 #endif
43 #ifndef FlashPixFormat_h
44 #include "fpxformt.h"
45 #endif
46 #ifndef FlashPixUtils_h
47 #include "fpxutils.h"
48 #endif
49
50 #ifndef FPXBaselineView_h
51 #include "fpxlib.h"
52 #endif
53
54 #ifndef BufferDesc_h
55 #include "buffdesc.h"
56 #endif
57
58 // Constants
59 // ---------
60
61 // Variables
62 // ---------
63
64 // ----------------------------------------------------------------------------
65 // Internal Functions
66 // ----------------------------------------------------------------------------
67
68 // ----------------------------------------------------------------------------
69 // Member Functions
70 // ----------------------------------------------------------------------------
71
72 // ----------------------------------------------------------------------------
73 // External functions used by C code :
74 // This is the interface of the Baseline FlashPix Viewing Toolkit
75 // ----------------------------------------------------------------------------
76
77
78 // World tools :
79
FPX_CreateWorld(FPXWorld ** theWorld,float width,float height,FPXColorspace backgroundColorspace,FPXBackground backgroundColor)80 FPXStatus FPX_CreateWorld (
81 FPXWorld** theWorld,
82 float width,
83 float height,
84 FPXColorspace backgroundColorspace,
85 FPXBackground backgroundColor)
86 {
87 FPXStatus status = FPX_OK;
88
89 *theWorld = new ViewWorld (width, height, 0);
90
91 if (!*theWorld)
92 status = FPX_SEVER_INIT_ERROR;
93 else
94 FPX_SetViewBackgroundColor(backgroundColorspace,backgroundColor);
95
96 return status;
97 }
98
FPX_DeleteWorld(FPXWorld * theWorld)99 FPXStatus FPX_DeleteWorld (
100 FPXWorld* theWorld)
101 {
102 if (theWorld == NULL) {
103 return FPX_INVALID_FPX_HANDLE;
104 } else {
105 delete theWorld;
106 return FPX_OK;
107 }
108 }
109
110 // Management of the list of images :
111
FPX_AddImage(FPXWorld * theWorld,FPXImageInWorld ** theImage,FPXImageHandle * theFPX)112 FPXStatus FPX_AddImage (
113 FPXWorld* theWorld,
114 FPXImageInWorld** theImage,
115 FPXImageHandle* theFPX)
116 {
117
118 FPXStatus status = FPX_OK;
119
120 *theImage = NULL;
121 if (theWorld) {
122 if (theWorld->AddImage (theFPX))
123 status = FPX_INVALID_FPX_HANDLE;
124 else
125 theWorld->Current (theImage);
126 }
127 else
128 status = FPX_INVALID_FPX_HANDLE;
129
130 return status;
131 }
132
FPX_DeleteImage(FPXWorld * theWorld,FPXImageInWorld * theImage)133 FPXStatus FPX_DeleteImage (
134 FPXWorld* theWorld,
135 FPXImageInWorld* theImage)
136 {
137 FPXStatus status = FPX_OK;
138
139 if (theWorld) {
140 if (theWorld->DeleteImage (theImage))
141 status = FPX_INVALID_FPX_HANDLE;
142 }
143 else
144 status = FPX_INVALID_FPX_HANDLE;
145
146 return status;
147 }
148
FPX_GetFirstImage(FPXWorld * theWorld,FPXImageInWorld ** theImage)149 FPXStatus FPX_GetFirstImage (
150 FPXWorld* theWorld,
151 FPXImageInWorld** theImage)
152 {
153 FPXStatus status = FPX_OK;
154
155 if (theWorld) {
156 if (theWorld->First (theImage))
157 status = FPX_INVALID_FPX_HANDLE;
158 }
159 else
160 status = FPX_INVALID_FPX_HANDLE;
161
162 return status;
163 }
164
FPX_GetLastImage(FPXWorld * theWorld,FPXImageInWorld ** theImage)165 FPXStatus FPX_GetLastImage (
166 FPXWorld* theWorld,
167 FPXImageInWorld** theImage)
168 {
169 FPXStatus status = FPX_OK;
170
171 if (theWorld) {
172 if (theWorld->Last (theImage))
173 status = FPX_INVALID_FPX_HANDLE;
174 }
175 else
176 status = FPX_INVALID_FPX_HANDLE;
177
178 return status;
179 }
180
FPX_GetCurrentImage(FPXWorld * theWorld,FPXImageInWorld ** theImage)181 FPXStatus FPX_GetCurrentImage (
182 FPXWorld* theWorld,
183 FPXImageInWorld** theImage)
184 {
185 FPXStatus status = FPX_OK;
186
187 if (theWorld) {
188 if (theWorld->Current (theImage))
189 status = FPX_INVALID_FPX_HANDLE;
190 }
191 else
192 status = FPX_INVALID_FPX_HANDLE;
193
194 return status;
195 }
196
FPX_NextImage(FPXWorld * theWorld,FPXImageInWorld ** theImage)197 FPXStatus FPX_NextImage (
198 FPXWorld* theWorld,
199 FPXImageInWorld** theImage)
200 {
201 FPXStatus status = FPX_OK;
202
203 if (theWorld) {
204 if (theWorld->Next (theImage))
205 status = FPX_INVALID_FPX_HANDLE;
206 }
207 else
208 status = FPX_INVALID_FPX_HANDLE;
209
210 return status;
211 }
212
FPX_PreviousImage(FPXWorld * theWorld,FPXImageInWorld ** theImage)213 FPXStatus FPX_PreviousImage (
214 FPXWorld* theWorld,
215 FPXImageInWorld** theImage)
216 {
217 FPXStatus status = FPX_OK;
218
219 if (theWorld) {
220 if (theWorld->Previous (theImage))
221 status = FPX_INVALID_FPX_HANDLE;
222 }
223 else
224 status = FPX_INVALID_FPX_HANDLE;
225
226 return status;
227 }
228
229 // Image positioning tools :
230
FPX_UseAlphaChannel(FPXImageInWorld * theImage,FPXbool useAlphaChannel)231 FPXStatus FPX_UseAlphaChannel (
232 FPXImageInWorld* theImage,
233 FPXbool useAlphaChannel)
234 {
235 FPXStatus status = FPX_OK;
236
237 if (theImage) {
238 if (theImage->UseAlphaChannel (useAlphaChannel))
239 status = FPX_INVALID_FPX_HANDLE;
240 }
241 else
242 status = FPX_INVALID_FPX_HANDLE;
243
244 return status;
245 }
246
FPX_InvertAlphaChannel(FPXImageInWorld * theImage,FPXbool inverseAlpha)247 FPXStatus FPX_InvertAlphaChannel (
248 FPXImageInWorld* theImage,
249 FPXbool inverseAlpha)
250 {
251 FPXStatus status = FPX_OK;
252
253 if (theImage) {
254 if (theImage->InvertAlphaChannel (inverseAlpha))
255 status = FPX_INVALID_FPX_HANDLE;
256 }
257 else
258 status = FPX_INVALID_FPX_HANDLE;
259
260 return status;
261 }
262
FPX_SetImageSize(FPXImageInWorld * theImage,float width,float height)263 FPXStatus FPX_SetImageSize (
264 FPXImageInWorld* theImage,
265 float width,
266 float height)
267 {
268 FPXStatus status = FPX_OK;
269
270 if (theImage) {
271 if (theImage->SetImageSize (width, height))
272 status = FPX_INVALID_FPX_HANDLE;
273 }
274 else
275 status = FPX_INVALID_FPX_HANDLE;
276
277 return status;
278 }
279
FPX_SetImageTransform(FPXImageInWorld * theImage,float x0,float y0,float m11,float m12,float m21,float m22)280 FPXStatus FPX_SetImageTransform (
281 FPXImageInWorld* theImage,
282 float x0, float y0,
283 float m11, float m12, float m21, float m22)
284 {
285 FPXStatus status = FPX_OK;
286
287 if (theImage)
288 theImage->SetPosition (x0, y0, m11, m12, m21, m22);
289 else
290 status = FPX_INVALID_FPX_HANDLE;
291
292 return status;
293 }
294
295
FPX_ApplyImageTransform(FPXImageInWorld * theImage,float x0,float y0,float m11,float m12,float m21,float m22)296 FPXStatus FPX_ApplyImageTransform (
297 FPXImageInWorld* theImage,
298 float x0, float y0,
299 float m11, float m12, float m21, float m22)
300 {
301 FPXStatus status = FPX_OK;
302
303 if (theImage)
304 theImage->ApplyTransform (x0, y0, m11, m12, m21, m22);
305 else
306 status = FPX_INVALID_FPX_HANDLE;
307
308 return status;
309 }
310
311
FPX_TranslateImage(FPXImageInWorld * theImage,float dx,float dy)312 FPXStatus FPX_TranslateImage (
313 FPXImageInWorld* theImage,
314 float dx, float dy)
315 {
316 FPXStatus status = FPX_OK;
317
318 if (theImage)
319 theImage->Translate (dx, dy);
320 else
321 status = FPX_INVALID_FPX_HANDLE;
322
323 return status;
324 }
325
326
FPX_RotateImage(FPXImageInWorld * theImage,float x0,float y0,float theta)327 FPXStatus FPX_RotateImage (
328 FPXImageInWorld* theImage,
329 float x0, float y0,
330 float theta)
331 {
332 FPXStatus status = FPX_OK;
333
334 if (theImage)
335 theImage->Rotate (x0, y0, theta);
336 else
337 status = FPX_INVALID_FPX_HANDLE;
338
339 return status;
340 }
341
342
FPX_ScaleImage(FPXImageInWorld * theImage,float x0,float y0,float sx,float sy)343 FPXStatus FPX_ScaleImage (
344 FPXImageInWorld* theImage,
345 float x0, float y0,
346 float sx, float sy)
347 {
348 FPXStatus status = FPX_OK;
349
350 if (theImage)
351 theImage->Scale (x0, y0, sx, sy);
352 else
353 status = FPX_INVALID_FPX_HANDLE;
354
355 return status;
356 }
357
358
FPX_ShearHorizontal(FPXImageInWorld * theImage,float x0,float y0,float sh)359 FPXStatus FPX_ShearHorizontal (
360 FPXImageInWorld* theImage,
361 float x0, float y0,
362 float sh)
363 {
364 FPXStatus status = FPX_OK;
365
366 if (theImage)
367 theImage->ShearHorizontal (x0, y0, sh);
368 else
369 status = FPX_INVALID_FPX_HANDLE;
370
371 return status;
372 }
373
374
FPX_ShearVertical(FPXImageInWorld * theImage,float x0,float y0,float sh)375 FPXStatus FPX_ShearVertical (
376 FPXImageInWorld* theImage,
377 float x0, float y0,
378 float sh)
379 {
380 FPXStatus status = FPX_OK;
381
382 if (theImage)
383 theImage->ShearVertical (x0, y0, sh);
384 else
385 status = FPX_INVALID_FPX_HANDLE;
386
387 return status;
388 }
389
390
FPX_FlipHorizontal(FPXImageInWorld * theImage,float x0,float y0)391 FPXStatus FPX_FlipHorizontal (
392 FPXImageInWorld* theImage,
393 float x0, float y0)
394 {
395 FPXStatus status = FPX_OK;
396
397 if (theImage)
398 theImage->FlipHorizontal (x0, y0);
399 else
400 status = FPX_INVALID_FPX_HANDLE;
401
402 return status;
403 }
404
405
FPX_FlipVertical(FPXImageInWorld * theImage,float x0,float y0)406 FPXStatus FPX_FlipVertical (
407 FPXImageInWorld* theImage,
408 float x0, float y0)
409 {
410 FPXStatus status = FPX_OK;
411
412 if (theImage)
413 theImage->FlipVertical (x0, y0);
414 else
415 status = FPX_INVALID_FPX_HANDLE;
416
417 return status;
418 }
419
420
FPX_GetOutlineParallelogram(FPXImageInWorld * theImage,float * x0,float * y0,float * x1,float * y1,float * x2,float * y2,float * x3,float * y3)421 FPXStatus FPX_GetOutlineParallelogram (
422 FPXImageInWorld* theImage,
423 float* x0, float* y0,
424 float* x1, float* y1,
425 float* x2, float* y2,
426 float* x3, float* y3)
427 {
428 FPXStatus status = FPX_OK;
429
430 if (theImage)
431 theImage->GetOutlineParallelogram (x0, y0, x1, y1, x2, y2, x3, y3);
432 else
433 status = FPX_INVALID_FPX_HANDLE;
434
435 return status;
436 }
437
FPX_GetOutlineRectangle(FPXImageInWorld * theImage,float * x0,float * y0,float * x1,float * y1)438 FPXStatus FPX_GetOutlineRectangle (
439 FPXImageInWorld* theImage,
440 float* x0, float* y0,
441 float* x1, float* y1)
442 {
443 FPXStatus status = FPX_OK;
444
445 if (theImage)
446 theImage->GetOutlineRectangle (x0, y0, x1, y1);
447 else
448 status = FPX_INVALID_FPX_HANDLE;
449
450 return status;
451 }
452
453
FPX_GetOrigin(FPXImageInWorld * theImage,float * x0,float * y0)454 FPXStatus FPX_GetOrigin (
455 FPXImageInWorld* theImage,
456 float* x0, float* y0)
457 {
458 FPXStatus status = FPX_OK;
459
460 if (theImage)
461 theImage->GetOrigin (x0, y0);
462 else
463 status = FPX_INVALID_FPX_HANDLE;
464
465 return status;
466 }
467
468
FPX_SetImageCrop(FPXImageInWorld * theImage,float x0,float y0,float x1,float y1)469 FPXStatus FPX_SetImageCrop (
470 FPXImageInWorld* theImage,
471 float x0, float y0,
472 float x1, float y1)
473 {
474 FPXStatus status = FPX_OK;
475
476 if (theImage)
477 status = theImage->SetImageCrop (x0, y0, x1, y1);
478 else
479 status = FPX_INVALID_FPX_HANDLE;
480
481 return status;
482 }
483
484
FPX_ResetImageCrop(FPXImageInWorld * theImage)485 FPXStatus FPX_ResetImageCrop (
486 FPXImageInWorld* theImage)
487 {
488 FPXStatus status = FPX_OK;
489
490 if (theImage)
491 theImage->ResetImageCrop ();
492 else
493 status = FPX_INVALID_FPX_HANDLE;
494
495 return status;
496 }
497
498
499
500 // View Window tools :
501
FPX_CreateWindow(FPXWorld * theWorld,FPXWindow ** theWindow,float x0,float y0,float width,float height,float resolution)502 FPXStatus FPX_CreateWindow (
503 FPXWorld* theWorld,
504 FPXWindow** theWindow,
505 float x0, float y0,
506 float width, float height,
507 float resolution)
508 {
509 FPXStatus status = FPX_OK;
510
511 if (!theWorld)
512 status = FPX_INVALID_FPX_HANDLE;
513 else {
514 // convert resolution in dot per unit into resol in dot per mm
515 // CAUTION : resolution unit is the inverse of a length,
516 // so ConvertToUnit convert resolution in dot per mm�
517 resolution = Toolkit_ConvertToUnit(resolution);
518
519 *theWindow = new ViewWindow (theWorld, x0, y0, width, height, resolution);
520 if (!*theWindow)
521 status = FPX_SEVER_INIT_ERROR;
522 }
523
524 return status;
525 }
526
FPX_DeleteWindow(FPXWindow * theWindow)527 FPXStatus FPX_DeleteWindow (
528 FPXWindow* theWindow)
529 {
530 if (theWindow == NULL) {
531 return FPX_INVALID_FPX_HANDLE;
532 } else {
533 delete theWindow;
534 return FPX_OK;
535 }
536 }
537
FPX_ReadWindowSample(FPXWindow * theWindow,int x0,int y0,FPXImageDesc * windowBufferInfo)538 FPXStatus FPX_ReadWindowSample (
539 FPXWindow* theWindow,
540 int x0, int y0,
541 FPXImageDesc* windowBufferInfo)
542 {
543 FPXStatus status = FPX_OK;
544 if (!theWindow)
545 status = FPX_INVALID_FPX_HANDLE;
546 else {
547 FPXBufferDesc sample(windowBufferInfo,4,4);
548 if (sample.Get32BitsBuffer() == NULL) {
549 return FPX_OBJECT_CREATION_FAILED;
550 }
551 if (sample.GetBaselineColorSpace() == NON_AUTHORIZED_SPACE)
552 status = FPX_INVALID_IMAGE_DESC;
553 else {
554 switch (theWindow->ReadSample (x0, y0, sample.Get32BitsBuffer(), sample.GetBaselineColorSpace())) {
555 case 0:
556 sample.UpdateDescriptor();
557 break;
558 default :
559 status = FPX_FILE_READ_ERROR;
560 break;
561 }
562 }
563 }
564 return status;
565 }
566
FPX_RefreshWindow(FPXWindow * theWindow,FPXImageDesc * windowBufferInfo)567 FPXStatus FPX_RefreshWindow (
568 FPXWindow* theWindow,
569 FPXImageDesc* windowBufferInfo)
570 {
571 FPXStatus status = FPX_OK;
572 if (!theWindow)
573 status = FPX_INVALID_FPX_HANDLE;
574 else {
575 int width, height;
576 //theWindow->GetWindowDefinition (&width, &height);
577 float tmpx0, tmpy0, tmpwidth, tmpheight, tmpresolution;
578 theWindow->GetWindowDefinition (&tmpx0, &tmpy0, &tmpwidth, &tmpheight, &tmpresolution);
579
580 theWindow->WorldToWindow(tmpx0+tmpwidth,tmpy0+tmpheight,&width,
581 &height);
582 FPXBufferDesc map(windowBufferInfo,width,height);
583 if (map.Get32BitsBuffer() == NULL) {
584 return FPX_OBJECT_CREATION_FAILED;
585 }
586 if (map.GetBaselineColorSpace() == NON_AUTHORIZED_SPACE)
587 status = FPX_INVALID_IMAGE_DESC;
588 else {
589 status = theWindow->Refresh (map.Get32BitsBuffer(),map.GetBaselineColorSpace(),width,height);
590 if (status == FPX_OK)
591 map.UpdateDescriptor();
592 }
593 }
594 return status;
595 }
596
597
FPX_TranslateWindow(FPXWindow * theWindow,float dx,float dy)598 FPXStatus FPX_TranslateWindow (
599 FPXWindow* theWindow,
600 float dx, float dy)
601 {
602 FPXStatus status = FPX_OK;
603
604 if (theWindow)
605 theWindow->Translate (dx, dy);
606 else
607 status = FPX_INVALID_FPX_HANDLE;
608
609 return status;
610 }
611
612
FPX_ResizeWindow(FPXWindow * theWindow,float width,float height)613 FPXStatus FPX_ResizeWindow (
614 FPXWindow* theWindow,
615 float width, float height)
616 {
617 FPXStatus status = FPX_OK;
618
619 if (theWindow)
620 theWindow->Resize (width, height);
621 else
622 status = FPX_INVALID_FPX_HANDLE;
623
624 return status;
625 }
626
627
FPX_ZoomWindow(FPXWindow * theWindow,float zoomRatio)628 FPXStatus FPX_ZoomWindow (
629 FPXWindow* theWindow,
630 float zoomRatio)
631 {
632 FPXStatus status = FPX_OK;
633
634 if (theWindow)
635 status = theWindow->Zoom (zoomRatio);
636 else
637 status = FPX_INVALID_FPX_HANDLE;
638
639 return status;
640 }
641
642
FPX_GetWindowDefinition(FPXWindow * theWindow,float * x0,float * y0,float * width,float * height,float * resolution)643 FPXStatus FPX_GetWindowDefinition (
644 FPXWindow* theWindow,
645 float* x0, float* y0,
646 float* width, float* height,
647 float* resolution)
648 {
649 FPXStatus status = FPX_OK;
650
651 if (theWindow)
652 theWindow->GetWindowDefinition (x0, y0, width, height, resolution);
653 else
654 status = FPX_INVALID_FPX_HANDLE;
655
656 return status;
657 }
658
659
FPX_WindowToWorld(FPXWindow * theWindow,int i,int j,float * x,float * y)660 FPXStatus FPX_WindowToWorld (
661 FPXWindow* theWindow,
662 int i, int j,
663 float* x, float* y)
664 {
665 FPXStatus status = FPX_OK;
666
667 if (theWindow)
668 theWindow->WindowToWorld (i, j, x, y);
669 else
670 status = FPX_INVALID_FPX_HANDLE;
671
672 return status;
673 }
674
675
FPX_WorldToWindow(FPXWindow * theWindow,float x,float y,int * i,int * j)676 FPXStatus FPX_WorldToWindow (
677 FPXWindow* theWindow,
678 float x, float y,
679 int* i, int* j)
680 {
681 FPXStatus status = FPX_OK;
682
683 if (theWindow)
684 theWindow->WorldToWindow (x, y, i, j);
685 else
686 status = FPX_INVALID_FPX_HANDLE;
687
688 return status;
689 }
690
691
FPX_SetImageInWorldContrastAdjustment(FPXImageInWorld * theImage,FPXContrastAdjustment * theContrastAdjustment)692 FPXStatus FPX_SetImageInWorldContrastAdjustment (
693 FPXImageInWorld* theImage,
694 FPXContrastAdjustment* theContrastAdjustment)
695 {
696 return ((FPXImageHandle*)(theImage))->SetImageContrastAdjustment(theContrastAdjustment);
697 }
698
FPX_GetImageInWorldContrastAdjustment(FPXImageInWorld * theImage,FPXContrastAdjustment * theContrastAdjustment)699 FPXStatus FPX_GetImageInWorldContrastAdjustment (
700 FPXImageInWorld* theImage,
701 FPXContrastAdjustment* theContrastAdjustment)
702 {
703 return FPX_GetImageContrastAdjustment ((FPXImageHandle*)(theImage), theContrastAdjustment);
704 }
705
FPX_SetImageInWorldColorTwistMatrix(FPXImageInWorld * theImage,FPXColorTwistMatrix * theColorTwistMatrix)706 FPXStatus FPX_SetImageInWorldColorTwistMatrix (
707 FPXImageInWorld* theImage,
708 FPXColorTwistMatrix* theColorTwistMatrix)
709 {
710 return ((FPXImageHandle*)(theImage))->SetImageColorTwistMatrix(theColorTwistMatrix);
711 }
712
FPX_GetImageInWorldColorTwistMatrix(FPXImageInWorld * theImage,FPXColorTwistMatrix * theColorTwistMatrix)713 FPXStatus FPX_GetImageInWorldColorTwistMatrix (
714 FPXImageInWorld* theImage,
715 FPXColorTwistMatrix* theColorTwistMatrix)
716 {
717 return FPX_GetImageColorTwistMatrix ((FPXImageHandle*)(theImage), theColorTwistMatrix);
718 }
719
FPX_SetImageInWorldFilteringValue(FPXImageInWorld * theImage,FPXFilteringValue * theFiltering)720 FPXStatus FPX_SetImageInWorldFilteringValue (
721 FPXImageInWorld* theImage,
722 FPXFilteringValue* theFiltering)
723 {
724 FPXStatus status = FPX_OK;
725 Boolean filterclamped = FALSE;
726
727 if(*theFiltering < -20.0)
728 {
729 *theFiltering = -20.0;
730 filterclamped = TRUE;
731 }
732
733 if( *theFiltering > 20.0)
734 {
735 *theFiltering = 20.0;
736 filterclamped = TRUE;
737 }
738 status = ((FPXImageHandle*)(theImage))->SetImageFilteringValue(theFiltering);
739
740 if(status == FPX_OK && filterclamped == TRUE)
741 status = FPX_W_COORDINATES_OUT_OF_RANGE;
742
743 return status;
744 }
745
FPX_GetImageInWorldFilteringValue(FPXImageInWorld * theImage,FPXFilteringValue * theFiltering)746 FPXStatus FPX_GetImageInWorldFilteringValue (
747 FPXImageInWorld* theImage,
748 FPXFilteringValue* theFiltering)
749 {
750 return FPX_GetImageFilteringValue ((FPXImageHandle*)(theImage), theFiltering);
751 }
752
753
FPX_GetImageInWorldAffineMatrix(FPXImageInWorld * theImage,FPXAffineMatrix * mat)754 FPXStatus FPX_GetImageInWorldAffineMatrix (
755 FPXImageInWorld* theImage,
756 FPXAffineMatrix* mat)
757 {
758 FPXStatus status = FPX_INVALID_FPX_HANDLE;
759
760 if(theImage){
761 float m11, m12, x0, m21, m22, y0;
762 theImage->GetPosition(&x0, &y0, &m11, &m12, &m21, &m22);
763
764 mat->a11 = m11; mat->a12 = m12; mat->a13 = 0; mat->a14 = x0;
765 mat->a21 = m21; mat->a22 = m22; mat->a23 = 0; mat->a24 = y0;
766 mat->a31 = 0; mat->a32 = 0; mat->a33 = 1; mat->a34 = 0;
767 mat->a41 = 0; mat->a42 = 0; mat->a43 = 0; mat->a44 = 1;
768 status = FPX_OK;
769 }
770 return status;
771 }
772
FPX_SetImageInWorldAffineMatrix(FPXImageInWorld * theImage,FPXAffineMatrix * mat)773 FPXStatus FPX_SetImageInWorldAffineMatrix (
774 FPXImageInWorld* theImage,
775 FPXAffineMatrix* mat)
776 {
777 FPXStatus status = FPX_INVALID_FPX_HANDLE;
778 if(theImage){
779 theImage->SetPosition(mat->a14, mat->a24, mat->a11, mat->a12, mat->a21, mat->a22);
780 status = FPX_OK;
781 }
782 return status;
783 }
784
785 // Formatted output tools :
786
FPX_SetPageSetup(FPXImageHandle * theFPX,FPXPage ** thePage,int width,int height,float rotation,FPXColorspace backgroundColorspace,FPXBackground backgroundColor)787 FPXStatus FPX_SetPageSetup (
788 FPXImageHandle* theFPX,
789 FPXPage** thePage,
790 int width,
791 int height,
792 float rotation,
793 FPXColorspace backgroundColorspace,
794 FPXBackground backgroundColor)
795 {
796 FPXStatus status = FPX_OK;
797
798 if (!theFPX)
799 status = FPX_INVALID_FPX_HANDLE;
800 else {
801 *thePage = new PageImage (theFPX, width, height, rotation);
802 if (!*thePage)
803 status = FPX_SEVER_INIT_ERROR;
804 else
805 FPX_SetViewBackgroundColor(backgroundColorspace,backgroundColor);
806 }
807
808 return status;
809 }
810
811 // Close Page :
FPX_ClosePage(FPXPage * thePage)812 FPXStatus FPX_ClosePage ( FPXPage* thePage)
813
814 {
815 if (thePage == NULL) {
816 return FPX_INVALID_FPX_HANDLE;
817 } else {
818 delete thePage;
819 return FPX_OK;
820 }
821 }
822
FPX_ReadPage(FPXPage * thePage,FPXImageDesc * renderingBuffer)823 FPXStatus FPX_ReadPage (
824 FPXPage* thePage,
825 FPXImageDesc* renderingBuffer)
826 {
827 FPXStatus status;
828 if (!thePage)
829 status = FPX_INVALID_FPX_HANDLE;
830 else {
831 long width, height;
832 thePage->GetPixelSize (&width, &height);
833 FPXBufferDesc image(renderingBuffer,width,height);
834 if (image.Get32BitsBuffer() == NULL) {
835 return FPX_OBJECT_CREATION_FAILED;
836 }
837 if (image.GetBaselineColorSpace() == NON_AUTHORIZED_SPACE)
838 status = FPX_INVALID_IMAGE_DESC;
839 else {
840 GtheSystemToolkit->SetUsedColorSpace(image.GetBaselineColorSpace());
841 status = thePage->ReadPage(image.Get32BitsBuffer());
842 if (status == FPX_OK)
843 image.UpdateDescriptor();
844 }
845 }
846 return status;
847 }
848
FPX_ReadPageLine(FPXPage * thePage,int lineNumber,FPXImageDesc * renderingBuffer)849 FPXStatus FPX_ReadPageLine (
850 FPXPage* thePage,
851 int lineNumber,
852 FPXImageDesc* renderingBuffer)
853 {
854 FPXStatus status;
855 if (!thePage)
856 status = FPX_INVALID_FPX_HANDLE;
857 else {
858 long width, height;
859 thePage->GetPixelSize (&width, &height);
860 FPXBufferDesc line(renderingBuffer,width,1);
861 if (line.Get32BitsBuffer() == NULL) {
862 return FPX_OBJECT_CREATION_FAILED;
863 }
864 if (line.GetBaselineColorSpace() == NON_AUTHORIZED_SPACE)
865 status = FPX_INVALID_IMAGE_DESC;
866 else {
867 GtheSystemToolkit->SetUsedColorSpace(line.GetBaselineColorSpace());
868 status = thePage->ReadPageLine (lineNumber, line.Get32BitsBuffer());
869 if (status == FPX_OK)
870 line.UpdateDescriptor();
871 }
872 }
873 return status;
874 }
875
876
877
878 // - EOF ----------------------------------------------------------------------
879