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 {
|
class ReaderWriterDOT : public osgDB::ReaderWriter {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual const char* className() const { return "DOT Writer"; }
|
virtual const char* className() const { return "DOT Writer"; }
|
||||||
virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"dot"); }
|
virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"dot"); }
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ class ReaderWriterSVG : public osgDB::ReaderWriter
|
|||||||
ReaderWriterSVG()
|
ReaderWriterSVG()
|
||||||
{
|
{
|
||||||
supportsExtension("svg","Scalar Vector Graphics format");
|
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"; }
|
virtual const char* className() const { return "SVG Image Reader"; }
|
||||||
@ -60,24 +62,41 @@ class ReaderWriterSVG : public osgDB::ReaderWriter
|
|||||||
osg::Image *image;
|
osg::Image *image;
|
||||||
if (options)
|
if (options)
|
||||||
{
|
{
|
||||||
unsigned int w=0, h=0;
|
|
||||||
std::string op = options->getOptionString();
|
std::string op = options->getOptionString();
|
||||||
size_t i = op.find("x");
|
|
||||||
|
|
||||||
std::stringstream ss1(op.substr(0, i));
|
size_t i = op.find("x");
|
||||||
std::stringstream ss2(op.substr(i+1, op.size()));
|
if (i!=std::string::npos)
|
||||||
ss1 >> w;
|
{
|
||||||
ss2 >> h;
|
|
||||||
if (w==0 || h==0){
|
std::stringstream ss1(op.substr(0, i));
|
||||||
image = createImage(handle, dimensionData.width, dimensionData.height);
|
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);
|
g_object_unref(handle);
|
||||||
image->setFileName(file);
|
image->setFileName(file);
|
||||||
return image;
|
return image;
|
||||||
|
Loading…
Reference in New Issue
Block a user