#include <epsstack.h>
Inheritance diagram for EPSStack:
Public Member Functions | |
EPSStack () | |
Constructor. Initialises scaling factor to be 1. | |
~EPSStack () | |
Destructor - deallocates all storage associated with the stack. | |
BOOL | Push (const INT32) |
Push a INT32 value onto the stack. | |
BOOL | Push (const FIXEDPOINT) |
Push a fixed point value onto the stack. | |
BOOL | Push (const double) |
Push a double value onto the stack. | |
BOOL | Push (const TCHAR *, BOOL IsName=FALSE) |
Push a TCHAR* string item onto the stack. | |
BOOL | Push (const EPSCommand Cmd) |
Push an EPS command onto the stack. | |
BOOL | Pop (INT32 *) |
Pop a INT32 value from the top of the stack. If there is a floating point value on the stack, it is converted before being returned to the caller. | |
BOOL | Pop (UINT32 *) |
Pop a UINT32 value from the top of the stack. If there is a floating point value on the stack, it is converted before being returned to the caller. | |
BOOL | Pop (FIXEDPOINT *) |
Pop a double value from the top of the stack. If there is an integer value on top of the stack, it is converted to a floating point value before being returned to the caller. | |
BOOL | Pop (double *) |
Pop a double value from the top of the stack. If there is an integer value on top of the stack, it is converted to a floating point value before being returned to the caller. | |
BOOL | Pop (TCHAR *) |
Pop a TCHAR* string value from the top of the stack. | |
BOOL | Pop (StringBase *) |
Pop a string value from the top of the stack. | |
BOOL | PopCmd (EPSCommand *) |
Pop an EPS command from the top of the stack. | |
BOOL | PopCoord (INT32 *) |
Pop a INT32 value from the top of the stack. If there is a fixed point value on the stack, it is converted before being returned to the caller. The value is scaled before being returned, so that it is easy to cope with EPS files that use brainless coordinate schemes (i.e. all of them). Scaling factor is initially 1, but can be changed via SetCoordScaleFactor(). | |
BOOL | PopCoordPair (DocCoord *) |
Pop two INT32 values from the top of the stack. If they are in floating point format, they are converted before being returned to the caller. The coords are scaled and translated before being returned, so that it is easy to cope with EPS files that use brainless coordinate schemes (ArtWorks EPS are you listening?). Scaling factor is initially 1, but can be changed via SetCoordScaleFactor(). Origin is initially (0,0), but can be changed via SetCoordOrigin(). | |
BOOL | PopColour (PColourCMYK *, TintType Tint=TINT_NONE, FIXEDPOINT *TintVal=NULL, String_64 *pName=NULL) |
Extract CYMK values from an ArtWorks EPS format and convert to Camelot range. AWEPS colour values are in the range 0 to 1; this function converts them to the 0 to 255 range. See Also: EPSStack::PopColourRGB. | |
BOOL | PopColourRGB (INT32 *red, INT32 *green, INT32 *blue, TintType Tint=TINT_NONE, FIXEDPOINT *TintVal=NULL, String_64 *pName=NULL) |
Extract RGB values from a generic EPS format and convert to Camelot range. EPS colour values are in the range 0 to 1; this function converts them to the 0 to 255 range. See Also: EPSStack::PopColour. | |
BOOL | PopGrayScale (PColourCMYK *) |
Extract grayscale value from an EPS format file and convert to Camelot range. | |
BOOL | Pop (Matrix *, BOOL) |
Pop a matrix object from the EPS stack. | |
BOOL | PopArray (INT32 *, INT32 *) |
Pop a PostScript array object from the stack. | |
BOOL | Discard (UINT32 NumToDiscard=1, BOOL EvenCommands=FALSE) |
Discard a number of items from the stack, irrespective of their type. NB. The exception is that you cannot discard a command, only operands (e.g. strings, numbers or names) unless EvenCommands == TRUE. | |
BOOL | DiscardArray () |
Discard a PostScript array object from the stack. This is normally used when an EPS filter is not complete, but the file is still parsed correctly by discarding information that is npt yet needed/processed. | |
void | SetCoordScaleFactor (INT32 NewScaleFactor) |
Set the scale factor used by PopCoord(). Scaling factor is initially 1. | |
void | SetCoordOrigin (DocCoord NewOrigin) |
Set the translation values used by PopCoord(). Initially (0,0). | |
void | TranslateCoordOrigin (MILLIPOINT dx, MILLIPOINT dy) |
Translate the current origin for the EPS file by the given amounts. This is used when the %BoundingBox comment is encountered, so that the image appears in a sensible place. | |
void | SetXformMatrix (Matrix &) |
Sets up an additional transformation matrix to be used when decoding document coordinates (via EPSStack::PopCoordPair). When a transform matrix is active, all coords returned from PopCoordPair will have been transformed by the matrix after first having had the usual origin translation performed. The transformation matrix can be disabled by called SetNoXFormMatrix(). | |
void | SetNoXformMatrix () |
Disable the transformation matrix used by EPSStack::PopCoordPair(). See SetXFormMatrix() for details. | |
EPSType | GetType () |
Find out what type of object is on the top of the stack. The item is not removed from the stack by this operation. | |
EPSCommand | ReadCmd () |
Find out what command is on top of the stack. The command is not removed from the stack. Numbers, strings, names, etc. do not count as being commands. | |
void | Dump (EPSFilter *) |
Dump out the contents of the stack to the debug window. The stack is unchanged. | |
BOOL | IsEmpty () |
Test to see if the stack is empty. | |
Private Attributes | |
INT32 | ScaleFactor |
DocCoord | Origin |
Matrix | XformMatrix |
BOOL | UseXformMatrix |
Definition at line 166 of file epsstack.h.
|
Constructor. Initialises scaling factor to be 1.
Definition at line 195 of file epsstack.cpp. 00195 : List () 00196 { 00197 // Set scaling to unity. 00198 ScaleFactor = 1; 00199 00200 // Set origin to default 00201 Origin.x = 0; 00202 Origin.y = 0; 00203 00204 // By default, no additional transformation matrix is used. 00205 UseXformMatrix = FALSE; 00206 }
|
|
Destructor - deallocates all storage associated with the stack.
Definition at line 218 of file epsstack.cpp. 00219 { 00220 // Delete the contents of the list. 00221 DeleteAll (); 00222 }
|
|
Discard a number of items from the stack, irrespective of their type. NB. The exception is that you cannot discard a command, only operands (e.g. strings, numbers or names) unless EvenCommands == TRUE.
Definition at line 1244 of file epsstack.cpp. 01245 { 01246 // Check we can discard this many items 01247 if ( GetCount () < NumToDiscard ) 01248 return FALSE; 01249 01250 while (NumToDiscard > 0) 01251 { 01252 EPSStackItem *pItem = static_cast<EPSStackItem*> ( GetHead () ); 01253 01254 // Catch NULL pointers. 01255 if ( pItem == NULL ) 01256 { 01257 // Cannot discard any more list items. 01258 break; 01259 } 01260 01261 if((pItem->Type == EPSTYPE_COMMAND) && (EvenCommands == FALSE)) 01262 { // Cannot discard a command 01263 return FALSE; 01264 } 01265 01266 // Clean up any storage for this item 01267 RemoveHead (); 01268 delete pItem; 01269 01270 // Move to next item 01271 NumToDiscard--; 01272 } 01273 01274 return TRUE; 01275 }
|
|
Discard a PostScript array object from the stack. This is normally used when an EPS filter is not complete, but the file is still parsed correctly by discarding information that is npt yet needed/processed.
Definition at line 1394 of file epsstack.cpp. 01395 { 01396 if (GetType() != EPSTYPE_COMMAND) 01397 { 01398 TRACEUSER( "Tim", _T("EPSStack::DiscardArray: Expected ArrayEnd\n")); 01399 return FALSE; 01400 } 01401 01402 EPSCommand Cmd=EPSC_Invalid; 01403 PopCmd(&Cmd); 01404 if (Cmd != EPSC_ArrayEnd) 01405 { 01406 TRACEUSER( "Tim", _T("EPSStack::DiscardArray: Expected ArrayEnd\n")); 01407 return FALSE; 01408 } 01409 01410 // Discard the rest of the array 01411 for(;;) 01412 { 01413 if (IsEmpty()) 01414 { 01415 // Run out of operands! 01416 TRACEUSER( "Tim", _T("EPSStack::DiscardArray: Run out of operands\n")); 01417 return FALSE; 01418 } 01419 01420 if (GetType() != EPSTYPE_COMMAND) 01421 // Discard array member 01422 Discard(); 01423 else 01424 { 01425 EPSCommand Cmd = ReadCmd(); 01426 if (!PopCmd(&Cmd) || Cmd != EPSC_ArrayStart) 01427 { 01428 TRACEUSER( "Tim", _T("EPSStack::DiscardArray: Expected ArrayStart\n")); 01429 return FALSE; 01430 } 01431 else 01432 break; // exit loop - end of array found 01433 } 01434 } 01435 01436 // Array discarded ok 01437 return TRUE; 01438 }
|
|
Dump out the contents of the stack to the debug window. The stack is unchanged.
Definition at line 1517 of file epsstack.cpp. 01518 { 01519 #if defined(_DEBUG) 01520 if (!Error::IsUserName("Tim") && !Error::IsUserName("Ben")) 01521 return; 01522 01523 TRACE( _T("EPS STACK DUMP START\n\n")); 01524 01525 for ( DWORD i = 0; i < GetCount (); i++ ) 01526 { 01527 EPSStackItem *pItem = static_cast<EPSStackItem*> ( FindItem ( i ) ); 01528 01529 switch (pItem->Type) 01530 { 01531 case EPSTYPE_COMMAND: 01532 TRACE( _T("Command: %s\n"), pFilter->GetEPSCommand(pItem->Data.Cmd)); 01533 break; 01534 01535 case EPSTYPE_FIXEDPOINT: 01536 TRACE( _T("Fixed point: %f\n"), ((double) pItem->Data.FixedPoint.Long) / FixedPointScale); 01537 break; 01538 01539 case EPSTYPE_INT32: 01540 TRACE( _T("Long: %ld\n"), pItem->Data.Long); 01541 break; 01542 01543 case EPSTYPE_STRING: 01544 TRACE( _T("String: '%s'\n"), pItem->Data.pString); 01545 break; 01546 01547 case EPSTYPE_NAME: 01548 TRACE( _T("Name: '%s'\n"), pItem->Data.pString); 01549 break; 01550 01551 case EPSTYPE_DOUBLE: 01552 TRACE( _T("Double: %f\n"), pItem->Data.Double); 01553 break; 01554 01555 case EPSTYPE_EMPTY: 01556 case EPSTYPE_NONE: 01557 TRACE( _T("Empty/None\n")); 01558 break; 01559 01560 default: 01561 TRACE( _T("Unknown type\n")); 01562 break; 01563 } 01564 01565 } 01566 01567 TRACE( _T("\nEPS STACK DUMP END\n")); 01568 #endif 01569 }
|
|
Find out what type of object is on the top of the stack. The item is not removed from the stack by this operation.
Definition at line 1453 of file epsstack.cpp. 01454 { 01455 EPSStackItem *pItem = static_cast<EPSStackItem*> ( GetHead () ); 01456 01457 if ( pItem == NULL ) 01458 return EPSTYPE_NONE; 01459 else 01460 return pItem->Type; 01461 }
|
|
Test to see if the stack is empty.
Definition at line 1500 of file epsstack.cpp. 01501 { 01502 return ( GetCount () == 0 ); 01503 }
|
|
Pop a matrix object from the EPS stack.
Definition at line 1087 of file epsstack.cpp. 01088 { 01089 if (UseBrackets) 01090 { 01091 EPSCommand Cmd=EPSC_Invalid; 01092 PopCmd(&Cmd); 01093 if (Cmd != EPSC_ArrayEnd) 01094 return FALSE; 01095 } 01096 01097 // Extract the six array values from the stack. 01098 double M[6]; 01099 INT32 i = 5; 01100 for (i = 5; i >= 0; i--) 01101 { 01102 if (!Pop(&M[i])) 01103 return FALSE; 01104 } 01105 01106 if (UseBrackets) 01107 { 01108 EPSCommand Cmd=EPSC_Invalid; 01109 PopCmd(&Cmd); 01110 if (Cmd != EPSC_ArrayStart) 01111 return FALSE; 01112 } 01113 01114 // Convert the abcd values into FIXED16s, cos that's what we use. 01115 FIXED16 F16[4]; 01116 for (i = 0; i < 4; i++) 01117 { 01118 F16[i] = FIXED16(M[i]); 01119 } 01120 01121 // Convert the Tx and Ty to MILLIPOINTS, cos that's what we use. 01122 INT32 L1 = (INT32) (M[4] * 1000.0); 01123 INT32 L2 = (INT32) (M[5] * 1000.0); 01124 01125 // Construct the matrix in the variable supplied by the caller. 01126 *pMatrix = Matrix(F16[0], F16[1], F16[2], F16[3], L1, L2); 01127 01128 // Success 01129 return TRUE; 01130 }
|
|
Pop a string value from the top of the stack.
Definition at line 666 of file epsstack.cpp. 00667 { 00668 // Get pointer to the stack item. 00669 EPSStackItem *pItem = static_cast<EPSStackItem*> ( RemoveHead () ); 00670 00671 // Return error if no items on stack. 00672 if ( pItem == NULL ) 00673 return FALSE; 00674 00675 // Check that the item is of the correct type 00676 if ( pItem->Type == EPSTYPE_STRING ) 00677 { 00678 // Correct type - remove item from stack and return to caller. 00679 *pString = String_256(pItem->Data.pString); 00680 delete pItem; 00681 return TRUE; 00682 } 00683 else 00684 { 00685 // Tidy up the memory. 00686 delete pItem; 00687 00688 // Type mismatch - return error condition 00689 return FALSE; 00690 } 00691 }
|
|
Pop a TCHAR* string value from the top of the stack.
Definition at line 627 of file epsstack.cpp. 00628 { 00629 // Get pointer to the stack item. 00630 EPSStackItem *pItem = static_cast<EPSStackItem*> ( RemoveHead () ); 00631 00632 // Return error if no items on stack. 00633 if ( pItem == NULL ) 00634 return FALSE; 00635 00636 // Check that the item is of the correct type 00637 if ( pItem->Type == EPSTYPE_STRING ) 00638 { 00639 // Correct type - remove item from stack and return to caller. 00640 camStrcpy ( pString, pItem->Data.pString ); 00641 delete pItem; 00642 return TRUE; 00643 } 00644 else 00645 { 00646 // Tidy up the memory. 00647 delete pItem; 00648 00649 // Type mismatch - return error condition 00650 return FALSE; 00651 } 00652 }
|
|
Pop a double value from the top of the stack. If there is an integer value on top of the stack, it is converted to a floating point value before being returned to the caller.
Definition at line 577 of file epsstack.cpp. 00578 { 00579 // Get pointer to the stack item. 00580 EPSStackItem *pItem = static_cast<EPSStackItem*> ( RemoveHead () ); 00581 00582 // Return error if no items on stack. 00583 if ( pItem == NULL ) 00584 return FALSE; 00585 00586 // Check that the item is of the correct type 00587 switch ( pItem->Type ) 00588 { 00589 case EPSTYPE_INT32: 00590 // Correct type - remove item from stack and return to caller. 00591 *pDouble = static_cast<double> ( pItem->Data.Long ); 00592 break; 00593 00594 case EPSTYPE_FIXEDPOINT: 00595 // Perform implicit type conversion a la PostScript 00596 *pDouble = static_cast<double> ( pItem->Data.FixedPoint.Long ) / FixedPointScale; 00597 break; 00598 00599 case EPSTYPE_DOUBLE: 00600 // Perform implicit type conversion a la PostScript 00601 *pDouble = pItem->Data.Double; 00602 break; 00603 00604 default: 00605 // Type mismatch - return error condition 00606 return FALSE; 00607 } 00608 00609 // Delete item fron stack and return 00610 delete pItem; 00611 00612 return TRUE; 00613 }
|
|
Pop a double value from the top of the stack. If there is an integer value on top of the stack, it is converted to a floating point value before being returned to the caller.
Definition at line 525 of file epsstack.cpp. 00526 { 00527 // Get pointer to the stack item. 00528 EPSStackItem *pItem = static_cast<EPSStackItem*> ( RemoveHead () ); 00529 00530 // Return error if no items on stack. 00531 if ( pItem == NULL ) 00532 return FALSE; 00533 00534 // Check that the item is of the correct type 00535 switch (pItem->Type) 00536 { 00537 case EPSTYPE_INT32: 00538 // Correct type - remove item from stack and return to caller. 00539 pFixedPoint->Long = ( pItem->Data.Long * FixedPointScale ); 00540 break; 00541 00542 case EPSTYPE_FIXEDPOINT: 00543 // Perform implicit type conversion a la PostScript 00544 *pFixedPoint = pItem->Data.FixedPoint; 00545 break; 00546 00547 case EPSTYPE_DOUBLE: 00548 // Perform implicit type conversion a la PostScript 00549 pFixedPoint->Long = static_cast <INT32> ( pItem->Data.Double ); 00550 break; 00551 00552 default: 00553 // Type mismatch - return error condition 00554 return FALSE; 00555 } 00556 00557 // Delete item fron stack and return 00558 delete pItem; 00559 00560 return TRUE; 00561 }
|
|
Pop a UINT32 value from the top of the stack. If there is a floating point value on the stack, it is converted before being returned to the caller.
Definition at line 473 of file epsstack.cpp. 00474 { 00475 // Get pointer to the stack item. 00476 EPSStackItem *pItem = static_cast<EPSStackItem*> ( RemoveHead () ); 00477 00478 // Return error if no items on stack. 00479 if ( pItem == NULL ) 00480 return FALSE; 00481 00482 // Check that the item is of the correct type 00483 switch ( pItem->Type ) 00484 { 00485 case EPSTYPE_INT32: 00486 // Correct type - remove item from stack and return to caller. 00487 *pUint = static_cast<UINT32> ( pItem->Data.Long ); 00488 break; 00489 00490 case EPSTYPE_FIXEDPOINT: 00491 // Perform implicit type conversion a la PostScript 00492 *pUint = static_cast<UINT32> ( pItem->Data.FixedPoint.Long / FixedPointScale ); 00493 break; 00494 00495 case EPSTYPE_DOUBLE: 00496 // Perform implicit type conversion a la PostScript 00497 *pUint = static_cast<UINT32> ( pItem->Data.Double ); 00498 break; 00499 00500 default: 00501 // Type mismatch - return error condition 00502 return FALSE; 00503 } 00504 00505 // Delete item fron stack and return 00506 delete pItem; 00507 00508 return TRUE; 00509 }
|
|
Pop a INT32 value from the top of the stack. If there is a floating point value on the stack, it is converted before being returned to the caller.
Definition at line 422 of file epsstack.cpp. 00423 { 00424 // Get pointer to the stack item. 00425 EPSStackItem *pItem = static_cast<EPSStackItem*> ( RemoveHead () ); 00426 00427 // Return error if no items on stack. 00428 if ( pItem == NULL ) 00429 return FALSE; 00430 00431 // Check that the item is of the correct type 00432 switch ( pItem->Type ) 00433 { 00434 case EPSTYPE_INT32: 00435 // Correct type - remove item from stack and return to caller. 00436 *pLong = static_cast<INT32> ( pItem->Data.Long ); 00437 break; 00438 00439 case EPSTYPE_FIXEDPOINT: 00440 // Perform implicit type conversion a la PostScript 00441 *pLong = static_cast<INT32> ( pItem->Data.FixedPoint.Long / FixedPointScale ); 00442 break; 00443 00444 case EPSTYPE_DOUBLE: 00445 // Perform implicit type conversion a la PostScript 00446 *pLong = static_cast<INT32> ( pItem->Data.Double ); 00447 break; 00448 00449 default: 00450 // Type mismatch - return error condition 00451 return FALSE; 00452 } 00453 00454 // Delete item fron stack and return 00455 delete pItem; 00456 00457 return TRUE; 00458 }
|
|
Pop a PostScript array object from the stack.
Definition at line 1290 of file epsstack.cpp. 01291 { 01292 if (Array == NULL || Elements == NULL) 01293 return FALSE; 01294 01295 if (GetType() != EPSTYPE_COMMAND) 01296 { 01297 TRACEUSER( "Will", _T("EPSStack::PopArray: Expected ArrayEnd\n")); 01298 return FALSE; 01299 } 01300 01301 // First this we find should be the 'Array End' command (']') 01302 EPSCommand Cmd=EPSC_Invalid; 01303 PopCmd(&Cmd); 01304 if (Cmd != EPSC_ArrayEnd) 01305 { 01306 TRACEUSER( "Will", _T("EPSStack::PopArray: Expected ArrayEnd\n")); 01307 return FALSE; 01308 } 01309 01310 INT32 NumElements = 0; 01311 01312 // The array element will be popped off the stack backwards, 01313 // so we need to make a tempory array, so we can swap them, 01314 // around at the end. 01315 INT32* TempArray = new INT32[*Elements]; 01316 if (TempArray == NULL) 01317 return FALSE; 01318 01319 // Read the rest of the array 01320 for(;;) 01321 { 01322 if (IsEmpty()) 01323 { 01324 // Run out of operands! 01325 TRACEUSER( "Will", _T("EPSStack::PopArray: Run out of operands\n")); 01326 delete TempArray; 01327 return FALSE; 01328 } 01329 01330 if (GetType() != EPSTYPE_COMMAND) 01331 { 01332 // Pop the array member 01333 double Double=0.0; 01334 if (!Pop(&Double)) 01335 { 01336 delete TempArray; 01337 return FALSE; 01338 } 01339 01340 if (NumElements < *Elements) 01341 { 01342 TempArray[NumElements] = (INT32) (Double * EPSScaleFactor); 01343 NumElements++; 01344 } 01345 } 01346 else 01347 { 01348 EPSCommand Cmd = ReadCmd(); 01349 if (!PopCmd(&Cmd) || Cmd != EPSC_ArrayStart) 01350 { 01351 TRACEUSER( "Will", _T("EPSStack::PopArray: Expected ArrayStart\n")); 01352 delete TempArray; 01353 return FALSE; 01354 } 01355 else 01356 break; // exit loop - end of array found 01357 } 01358 } 01359 01360 *Elements = NumElements; // Actual number of elements read 01361 01362 // Now swap the elements so they are the correct way around. 01363 if (NumElements > 0) 01364 { 01365 INT32 LastEl = NumElements - 1; 01366 01367 for (INT32 el = 0; el < NumElements; el++) 01368 { 01369 Array[el] = TempArray[LastEl - el]; 01370 } 01371 } 01372 01373 delete TempArray; 01374 01375 // Array popped ok 01376 return TRUE; 01377 }
|
|
Pop an EPS command from the top of the stack.
Definition at line 706 of file epsstack.cpp. 00707 { 00708 // Get pointer to the stack item. 00709 EPSStackItem *pItem = static_cast<EPSStackItem*> ( RemoveHead () ); 00710 00711 // Return error if no items on stack. 00712 if ( pItem == NULL ) 00713 return FALSE; 00714 00715 // Check that the item is of the correct type 00716 if (pItem->Type == EPSTYPE_COMMAND) 00717 { 00718 // Correct type - remove item from stack and return to caller. 00719 *pCmd = pItem->Data.Cmd; 00720 delete pItem; 00721 return TRUE; 00722 } 00723 else 00724 { 00725 // Type mismatch - return error condition 00726 delete pItem; 00727 return FALSE; 00728 } 00729 }
|
|
Extract CYMK values from an ArtWorks EPS format and convert to Camelot range. AWEPS colour values are in the range 0 to 1; this function converts them to the 0 to 255 range. See Also: EPSStack::PopColourRGB.
TintVal - the value of the tint operand. pName - the textual name of this colour. If there is a tint, then the CMYK values are followed by a colour name and a tint value (0.0 to 1.0). The colour name is discarded, and the colour is adjusted according to the tint value found.
Definition at line 867 of file epsstack.cpp. 00869 { 00870 double Cyan, Magenta, Yellow, Key; 00871 FIXEDPOINT TintValue; 00872 TintValue=0; // Warning suppression 00873 00874 if (Tint != TINT_NONE) 00875 { 00876 // Get the tint. 00877 if (!Pop(&TintValue)) 00878 return FALSE; 00879 00880 // Does the caller want the name of the colour? 00881 if (pName == NULL) 00882 { 00883 // Name is not wanted - discard it 00884 if (!Discard()) 00885 return FALSE; 00886 } 00887 else 00888 { 00889 // Name is wanted - get it from the stack 00890 if (!Pop(pName)) 00891 return FALSE; 00892 } 00893 00894 ENSURE((TintValue >= 0) && (TintValue <= 1000), "Bad tint"); 00895 00896 // Convert Tint to sensible value, if required 00897 if (Tint == TINT_ILLUSTRATOR) 00898 TintValue = (1 * FixedPointScale) - (INT32) TintValue; 00899 00900 if (pTintVal != NULL) 00901 *pTintVal = TintValue; 00902 } 00903 00904 if (Pop(&Key) && Pop(&Yellow) && Pop(&Magenta) && Pop(&Cyan)) 00905 { 00906 if ((Cyan < 0.0) || (Cyan > 1.0) || (Magenta < 0.0) || (Magenta > 1.0) || 00907 (Yellow < 0.0) || (Yellow > 1.0) || (Key < 0.0) || (Key > 1.0)) 00908 // Invalid colour value 00909 return FALSE; 00910 00911 // Got the values ok - translate from 0->1 range to sensible range. 00912 // NB. Important that we round up here, because otherwise 8 bit values will 00913 // sometimes fail to match on boundary conditions. 00914 Col->Cyan = (INT32) ((Cyan * 255.0) + 0.5); 00915 Col->Magenta = (INT32) ((Magenta * 255.0) + 0.5); 00916 Col->Yellow = (INT32) ((Yellow * 255.0) + 0.5); 00917 Col->Key = (INT32) ((Key * 255.0) + 0.5); 00918 00919 if (Tint != TINT_NONE) 00920 { 00921 // Tint the colour 00922 Col->Cyan = (Col->Cyan * TintValue) / FixedPointScale; 00923 Col->Magenta = (Col->Magenta * TintValue) / FixedPointScale; 00924 Col->Yellow = (Col->Yellow * TintValue) / FixedPointScale; 00925 Col->Key = (Col->Key * TintValue) / FixedPointScale; 00926 } 00927 00928 return TRUE; 00929 } 00930 else 00931 return FALSE; 00932 }
|
|
Extract RGB values from a generic EPS format and convert to Camelot range. EPS colour values are in the range 0 to 1; this function converts them to the 0 to 255 range. See Also: EPSStack::PopColour.
TintVal - the value of the tint operand. pName - the textual name of this colour. NOTE: The tint is currently not supported for RGB colours, although the syntax has been kept to keep it consistent with the CMYK/Greyscale versions, as well to enable expansion of this function.
Definition at line 969 of file epsstack.cpp. 00971 { 00972 double tempRed, tempGreen, tempBlue; 00973 FIXEDPOINT TintValue; 00974 00975 if (Tint != TINT_NONE) 00976 { 00977 // Get the tint. 00978 if (!Pop(&TintValue)) 00979 return FALSE; 00980 00981 // Does the caller want the name of the colour? 00982 if (pName == NULL) 00983 { 00984 // Name is not wanted - discard it 00985 if (!Discard()) 00986 return FALSE; 00987 } 00988 else 00989 { 00990 // Name is wanted - get it from the stack 00991 if (!Pop(pName)) 00992 return FALSE; 00993 } 00994 00995 ENSURE((TintValue >= 0) && (TintValue <= 1000), "Bad tint"); 00996 00997 // Convert Tint to sensible value, if required 00998 if (Tint == TINT_ILLUSTRATOR) 00999 TintValue = (1 * FixedPointScale) - (INT32) TintValue; 01000 01001 if (pTintVal != NULL) 01002 *pTintVal = TintValue; 01003 } 01004 01005 if (Pop(&tempBlue) && Pop(&tempGreen) && Pop(&tempRed)) 01006 { 01007 if ((tempRed < 0.0) || (tempRed > 1.0) || 01008 (tempBlue < 0.0) || (tempBlue > 1.0) || 01009 (tempGreen < 0.0) || (tempGreen > 1.0)) 01010 // Invalid colour value 01011 return FALSE; 01012 01013 // Got the values ok - translate from 0->1 range to sensible range. 01014 // NB. Important that we round up here, because otherwise 8 bit values will 01015 // sometimes fail to match on boundary conditions. 01016 *red = (INT32) ((tempRed * 255.0) + 0.5); 01017 *green = (INT32) ((tempGreen * 255.0) + 0.5); 01018 *blue = (INT32) ((tempBlue * 255.0) + 0.5); 01019 01020 if (Tint != TINT_NONE) 01021 { 01022 // Tint the colour - Not currently done for RGB colours 01023 } 01024 01025 return TRUE; 01026 } 01027 else 01028 return FALSE; 01029 }
|
|
Pop a INT32 value from the top of the stack. If there is a fixed point value on the stack, it is converted before being returned to the caller. The value is scaled before being returned, so that it is easy to cope with EPS files that use brainless coordinate schemes (i.e. all of them). Scaling factor is initially 1, but can be changed via SetCoordScaleFactor().
Definition at line 748 of file epsstack.cpp. 00749 { 00750 // Get pointer to the stack item. 00751 EPSStackItem *pItem = static_cast<EPSStackItem*> ( RemoveHead () ); 00752 00753 // Return error if no items on stack. 00754 if ( pItem == NULL ) 00755 return FALSE; 00756 00757 // Check that the item is of the correct type 00758 switch ( pItem->Type ) 00759 { 00760 case EPSTYPE_INT32: 00761 // Correct type - remove item from stack and return to caller. 00762 *pLong = ScaleFactor * (pItem->Data.Long); 00763 break; 00764 00765 case EPSTYPE_FIXEDPOINT: 00766 // Perform implicit type conversion a la PostScript 00767 00768 // Fixed point values are stored as value * 1000, so if the ScaleFactor is 00769 // actually 1000, don't bother to scale - just return the value. 00770 if (ScaleFactor == FixedPointScale) 00771 *pLong = static_cast<INT32> ( pItem->Data.FixedPoint.Long ); 00772 else 00773 { 00774 // Perform the necessary scaling 00775 *pLong = static_cast<INT32> ( pItem->Data.FixedPoint.Long * 00776 ( static_cast<double> ( ScaleFactor ) ) ); 00777 *pLong /= FixedPointScale; 00778 } 00779 break; 00780 00781 case EPSTYPE_DOUBLE: 00782 // Perform implicit type conversion a la PostScript 00783 *pLong = static_cast<INT32> ( static_cast<double> ( ScaleFactor ) * 00784 pItem->Data.Double ); 00785 break; 00786 00787 default: 00788 // Type mismatch - return error condition 00789 return FALSE; 00790 } 00791 00792 // Delete item fron stack and return 00793 delete pItem; 00794 return TRUE; 00795 }
|
|
Pop two INT32 values from the top of the stack. If they are in floating point format, they are converted before being returned to the caller. The coords are scaled and translated before being returned, so that it is easy to cope with EPS files that use brainless coordinate schemes (ArtWorks EPS are you listening?). Scaling factor is initially 1, but can be changed via SetCoordScaleFactor(). Origin is initially (0,0), but can be changed via SetCoordOrigin().
Definition at line 817 of file epsstack.cpp. 00818 { 00819 if (PopCoord(&(pCoord->y)) && PopCoord(&(pCoord->x))) 00820 { 00821 // Use the transform matrix if necessary. 00822 if (UseXformMatrix) 00823 XformMatrix.transform((Coord *) pCoord, 1); 00824 00825 // Translate coord using given origin and return success. 00826 pCoord->x += Origin.x; 00827 pCoord->y += Origin.y; 00828 00829 return TRUE; 00830 } 00831 else 00832 return FALSE; 00833 }
|
|
Extract grayscale value from an EPS format file and convert to Camelot range.
Definition at line 1045 of file epsstack.cpp. 01046 { 01047 double Gray=0.0; 01048 01049 if (Pop(&Gray)) 01050 { 01051 if ((Gray < 0.0) || (Gray > 1.0)) 01052 // invalid gray scale value 01053 return FALSE; 01054 01055 // Got the grayscale ok - translate from 0->1 range to sensible range. 01056 PColourValue GrayVal = 255 - (static_cast<INT32> (Gray * 255)); 01057 01058 Col->Cyan = 0; 01059 Col->Magenta = 0; 01060 Col->Yellow = 0; 01061 Col->Key = static_cast<BYTE> ( GrayVal ); 01062 01063 return TRUE; 01064 } 01065 else 01066 return FALSE; 01067 }
|
|
Push an EPS command onto the stack.
Definition at line 385 of file epsstack.cpp. 00386 { 00387 EPSStackItem *pItem = new EPSStackItem; 00388 00389 // Ensure that the item has been created. 00390 if ( pItem == NULL) 00391 { 00392 // Clear the stack as the caller will now abort. 00393 DeleteAll (); 00394 00395 // Tell caller about the error 00396 ERROR ( _R(IDT_EPS_STACKLIMIT), FALSE ); 00397 } 00398 00399 // Initialise stack item. 00400 pItem->Init ( Cmd ); 00401 00402 // Add it to the list. 00403 AddHead ( pItem ); 00404 00405 return TRUE; 00406 }
|
|
Push a TCHAR* string item onto the stack.
Definition at line 344 of file epsstack.cpp. 00346 { 00347 EPSStackItem *pItem = new EPSStackItem; 00348 00349 // Ensure that the item has been created. 00350 if ( pItem == NULL) 00351 { 00352 // Clear the stack as the caller will now abort. 00353 DeleteAll (); 00354 00355 // Tell caller about the error 00356 ERROR ( _R(IDT_EPS_STACKLIMIT), FALSE ); 00357 } 00358 00359 // Try to copy string 00360 TCHAR *NewStr = new TCHAR[camStrlen(pString) + 1]; 00361 ERRORIF(NewStr == NULL, _R(IDT_EPS_NOMEMORY), FALSE); 00362 camStrcpy(NewStr, pString); 00363 00364 // Initialise stack item. 00365 pItem->Init ( NewStr ); 00366 00367 // Add it to the list. 00368 AddHead ( pItem ); 00369 00370 return TRUE; 00371 }
|
|
Push a double value onto the stack.
Definition at line 308 of file epsstack.cpp. 00309 { 00310 EPSStackItem *pItem = new EPSStackItem; 00311 00312 // Ensure that the item has been created. 00313 if ( pItem == NULL) 00314 { 00315 // Clear the stack as the caller will now abort. 00316 DeleteAll (); 00317 00318 // Tell caller about the error 00319 ERROR ( _R(IDT_EPS_STACKLIMIT), FALSE ); 00320 } 00321 00322 // Initialise stack item. 00323 pItem->Init ( Double ); 00324 00325 // Add it to the list. 00326 AddHead ( pItem ); 00327 00328 return TRUE; 00329 }
|
|
Push a fixed point value onto the stack.
Definition at line 272 of file epsstack.cpp. 00273 { 00274 EPSStackItem *pItem = new EPSStackItem; 00275 00276 // Ensure that the item has been created. 00277 if ( pItem == NULL) 00278 { 00279 // Clear the stack as the caller will now abort. 00280 DeleteAll (); 00281 00282 // Tell caller about the error 00283 ERROR ( _R(IDT_EPS_STACKLIMIT), FALSE ); 00284 } 00285 00286 // Initialise stack item. 00287 pItem->Init ( FixedPoint ); 00288 00289 // Add it to the list. 00290 AddHead ( pItem ); 00291 00292 return TRUE; 00293 }
|
|
Push a INT32 value onto the stack.
Definition at line 236 of file epsstack.cpp. 00237 { 00238 EPSStackItem *pItem = new EPSStackItem; 00239 00240 // Ensure that the item has been created. 00241 if ( pItem == NULL) 00242 { 00243 // Clear the stack as the caller will now abort. 00244 DeleteAll (); 00245 00246 // Tell caller about the error 00247 ERROR ( _R(IDT_EPS_STACKLIMIT), FALSE ); 00248 } 00249 00250 // Initialise stack item. 00251 pItem->Init ( Long ); 00252 00253 // Add it to the list. 00254 AddHead ( pItem ); 00255 00256 return TRUE; 00257 }
|
|
Find out what command is on top of the stack. The command is not removed from the stack. Numbers, strings, names, etc. do not count as being commands.
Definition at line 1478 of file epsstack.cpp. 01479 { 01480 EPSStackItem *pItem = static_cast<EPSStackItem*> ( GetHead () ); 01481 01482 if ( ( pItem == NULL ) || ( pItem->Type != EPSTYPE_COMMAND ) ) 01483 return EPSC_Invalid; 01484 else 01485 return pItem->Data.Cmd; 01486 }
|
|
Set the translation values used by PopCoord(). Initially (0,0).
Definition at line 1161 of file epsstack.cpp. 01162 { 01163 Origin = NewOrigin; 01164 }
|
|
Set the scale factor used by PopCoord(). Scaling factor is initially 1.
Definition at line 1144 of file epsstack.cpp. 01145 { 01146 ScaleFactor = NewScaleFactor; 01147 }
|
|
Disable the transformation matrix used by EPSStack::PopCoordPair(). See SetXFormMatrix() for details.
Definition at line 1223 of file epsstack.cpp. 01224 { 01225 UseXformMatrix = FALSE; 01226 }
|
|
Sets up an additional transformation matrix to be used when decoding document coordinates (via EPSStack::PopCoordPair). When a transform matrix is active, all coords returned from PopCoordPair will have been transformed by the matrix after first having had the usual origin translation performed. The transformation matrix can be disabled by called SetNoXFormMatrix().
Definition at line 1204 of file epsstack.cpp. 01205 { 01206 // Install the new matrix 01207 XformMatrix = NewMatrix; 01208 UseXformMatrix = TRUE; 01209 }
|
|
Translate the current origin for the EPS file by the given amounts. This is used when the %BoundingBox comment is encountered, so that the image appears in a sensible place.
Definition at line 1180 of file epsstack.cpp.
|
|
Definition at line 225 of file epsstack.h. |
|
Definition at line 224 of file epsstack.h. |
|
Definition at line 228 of file epsstack.h. |
|
Definition at line 227 of file epsstack.h. |