Convert a pixel value into a millimeter value using sAIUser->IUAIRealToStringUnits
Hi all,
I have a value with unit pixel or document points and want to convert it to a value with unit millimeter.
The only way I have found so far, is the following:
AIReal pixelValue = 0.316522;
ai::UnicodeString unicodeStr;
sAIUser->IUAIRealToStringUnits(pixelValue, -1, unicodeStr);
//unicodeStr = "0,1117 mm"
AIReal millimeterValue = 0;
sAIUser->IUStringToAIReal(unicodeStr, &millimeterValue);
//millimeterValue = 0.1117That is exactly the result I want to have!
But when I change the ruler-unit in Illustrator from millimeter to e.g. pixel, I get this result:
AIReal pixelValue = 0.316522;
ai::UnicodeString unicodeStr;
sAIUser->IUAIRealToStringUnits(pixelValue, -1, unicodeStr);
//unicodeStr = "0,3165 px"
AIReal millimeterValue = 0;
sAIUser->IUStringToAIReal(unicodeStr, &millimeterValue);
//millimeterValue = 0.3165What can I do to always convert the pixel value to the corresponding millimeter value, regardless of which ruler-unit is set in Illustrator?
Thank you very much in advance.
Best Regards,
Fabian
