Added "rs=value" Options support to SVG plugin
This commit is contained in:
parent
7f0baaab61
commit
a8924a7b36
@ -17,6 +17,7 @@
|
||||
|
||||
class ReaderWriterDOT : public osgDB::ReaderWriter {
|
||||
public:
|
||||
|
||||
virtual const char* className() const { return "DOT Writer"; }
|
||||
virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"dot"); }
|
||||
|
||||
|
@ -36,6 +36,8 @@ class ReaderWriterSVG : public osgDB::ReaderWriter
|
||||
ReaderWriterSVG()
|
||||
{
|
||||
supportsExtension("svg","Scalar Vector Graphics format");
|
||||
supportsOption("1024x512","Set resolution of the image generated by SVG");
|
||||
supportsOption("rs=2.0","Scale the resolution of the image generated by SVG");
|
||||
}
|
||||
|
||||
virtual const char* className() const { return "SVG Image Reader"; }
|
||||
@ -60,24 +62,41 @@ class ReaderWriterSVG : public osgDB::ReaderWriter
|
||||
osg::Image *image;
|
||||
if (options)
|
||||
{
|
||||
unsigned int w=0, h=0;
|
||||
std::string op = options->getOptionString();
|
||||
size_t i = op.find("x");
|
||||
|
||||
std::stringstream ss1(op.substr(0, i));
|
||||
std::stringstream ss2(op.substr(i+1, op.size()));
|
||||
ss1 >> w;
|
||||
ss2 >> h;
|
||||
if (w==0 || h==0){
|
||||
image = createImage(handle, dimensionData.width, dimensionData.height);
|
||||
size_t i = op.find("x");
|
||||
if (i!=std::string::npos)
|
||||
{
|
||||
|
||||
std::stringstream ss1(op.substr(0, i));
|
||||
std::stringstream ss2(op.substr(i+1, op.size()));
|
||||
unsigned int w=0, h=0;
|
||||
ss1 >> w;
|
||||
ss2 >> h;
|
||||
if (w!=0 && h!=0)
|
||||
{
|
||||
dimensionData.width = w;
|
||||
dimensionData.height = h;
|
||||
}
|
||||
}
|
||||
else{
|
||||
image = createImage(handle, w, h);
|
||||
|
||||
i = op.find("rs=");
|
||||
if (i!=std::string::npos)
|
||||
{
|
||||
|
||||
std::stringstream ss(op.substr(i+3, op.size()));
|
||||
double scale;
|
||||
ss >> scale;
|
||||
if (scale!=0.0)
|
||||
{
|
||||
dimensionData.width = dimensionData.width * scale;
|
||||
dimensionData.height = dimensionData.height * scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
image = createImage(handle, dimensionData.width, dimensionData.height);
|
||||
}
|
||||
|
||||
image = createImage(handle, dimensionData.width, dimensionData.height);
|
||||
|
||||
g_object_unref(handle);
|
||||
image->setFileName(file);
|
||||
return image;
|
||||
|
Loading…
Reference in New Issue
Block a user