Changeset 9158 for OpenSceneGraph/trunk/examples/osgpdf/osgpdf.cpp
- Timestamp:
- 11/12/08 15:57:30 (5 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/examples/osgpdf/osgpdf.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgpdf/osgpdf.cpp
r9156 r9158 7 7 #include <osgViewer/ViewerEventHandlers> 8 8 9 #include <osgDB/FileUtils> 10 #include <osgDB/FileNameUtils> 9 11 #include <osgDB/ReadFile> 10 12 … … 94 96 { 95 97 osg::notify(osg::NOTICE)<<"open("<<filename<<")"<<std::endl; 98 99 std::string foundFile = osgDB::findDataFile(filename); 100 if (foundFile.empty()) 101 { 102 osg::notify(osg::NOTICE)<<"could not find filename="<<filename<<std::endl; 103 return false; 104 } 105 106 osg::notify(osg::NOTICE)<<"foundFile = "<<foundFile<<std::endl; 107 foundFile = osgDB::getRealPath(foundFile); 108 osg::notify(osg::NOTICE)<<"foundFile = "<<foundFile<<std::endl; 96 109 97 110 static bool gTypeInit = false; … … 99 112 if(!gTypeInit) 100 113 { 101 g_type_init();102 103 gTypeInit = true;114 g_type_init(); 115 116 gTypeInit = true; 104 117 } 105 106 PopplerDocument* doc = poppler_document_new_from_file(filename.c_str(), NULL, NULL); 118 119 std::string uri = std::string("file:") + foundFile; 120 121 PopplerDocument* doc = poppler_document_new_from_file(uri.c_str(), NULL, NULL); 107 122 if (!doc) 108 123 { 109 osg::notify(osg::NOTICE)<<" could not open("<<filename<<") "<<std::endl;124 osg::notify(osg::NOTICE)<<" could not open("<<filename<<"), uri="<<uri<<std::endl; 110 125 111 126 return false; … … 171 186 poppler_page_get_size(page, &w, &h); 172 187 173 create((unsigned int)(w ),(unsigned int)(h));188 create((unsigned int)(w*2.0),(unsigned int)(h*2.0)); 174 189 175 190 double r = 1.0; … … 181 196 182 197 cairo_set_source_rgba(_context, r, g, b, a); 183 cairo_rectangle(_context, 0.0, 0.0, w, h);198 cairo_rectangle(_context, 0.0, 0.0, double(s()), double(t())); 184 199 cairo_fill(_context); 185 200 201 cairo_scale(_context, double(s())/w, double(t())/h); 202 186 203 poppler_page_render(page, getContext()); 187 204 205 188 206 cairo_restore(_context); 189 207
