static void TestGenerateXPSFromJPEG()
{
string lFile1 = "../../examples/testfiles/siena.jpg";
string lOutputFile = "../../examples/output/siena.xps";
NOHandler lPackage = NOPackage_createFromImage(System.Text.Encoding.UTF8.GetBytes(lFile1));
NOPackage_writePackageToFile(ref lPackage, System.Text.Encoding.UTF8.GetBytes(lOutputFile));
NOPackage_destroyPackage(ref lPackage);
}
void createXPSFromJPEG()
{
NOPackage *lPackage = NOPackage::createPackage(true);
NODocument lSourceDoc1=lPackage->getDocument(0);
NOPage lPage = lSourceDoc1.createPage();
NOImage lImage = lPage.addImage("../testfiles/siena.jpg");
NOXFixedPage lFixedPage = lPage.getFixedPage();
UInt32 lWidth = lImage.getWidthInPixels();
double lXFactor = lImage.getXResolution() / 96.;
UInt32 lHeight = lImage.getHeightInPixels();
double lYFactor = lImage.getYResolution() / 96.;
lFixedPage.intialize(lWidth*lXFactor,lHeight*lYFactor);
NOXCanvas lCanvas = lFixedPage.createCanvas(0);
UTF8String lFilename = lImage.getFileName();
char lRectangle[100];
sprintf(lRectangle,"M 0,0 L %f,0 %f,%f 0,%f z",
lWidth*lXFactor,lWidth*lXFactor,
lHeight*lYFactor,lHeight*lYFactor);
NOXPath lXPath = lCanvas.createPath(0);
lXPath.setData(NOString(lRectangle));
NOXCP_Brush lBrush = lXPath.createPathFill(0);
NOXImageBrush lImageBrush = lBrush.createImageBrush(0);
sprintf(lRectangle,"0,0,%f,%f",lWidth/lXFactor,lHeight/lYFactor);
lImageBrush.setViewbox(NOXViewBox(NOXStringBase(NOString(lRectangle))));
sprintf(lRectangle,"0,0,%f,%f",lWidth*lXFactor,lHeight*lYFactor);
lImageBrush.setViewport(NOXViewBox(NOString(lRectangle)));
lImageBrush.setTileMode(NiXPSObjects::None);
lImageBrush.setViewboxUnits(NiXPSObjects::Absolute);
lImageBrush.setViewportUnits(NiXPSObjects::Absolute);
NCommon::UTF8String lBaseString(lImage.getPartName());
lBaseString = "/" + lBaseString;
lImageBrush.setImageSource(NOString(lBaseString.c_str()));
lPackage->writePackageToFile(pOut);
NOPackage::destroyPackage(lPackage);
}
Subscribe to
Posts [Atom]