All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ExternalGraphicRenderer.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/widgets/ExternalGraphicRenderer.cpp
22 
23  \brief A concrete renderer based on Qt4 for conversion of Symbology Enconding External Graphic elements to an image pattern.
24 */
25 
26 // TerraLib
27 #include "../../../se/ExternalGraphic.h"
28 #include "../../../xlink/SimpleLink.h"
29 #include "../Utils.h"
31 
32 // Qt
33 #include <QImage>
34 
36  : te::map::AbstractExternalGraphicRenderer()
37 {
38 }
39 
41 {
42 }
43 
45 {
46  /* For while this method only looks for URI on OnlineResource
47  and consider that the URI references a local image file. (Uba, Feb 2013) */
48 
49  const te::xl::SimpleLink* link = eg->getOnlineResource();
50  if(link == 0)
51  return 0;
52 
53  const std::string uri = link->getHref();
54  if(uri.empty())
55  return 0;
56 
57  // Try load the image
58  QImage img;
59  if(!img.load(uri.c_str()))
60  return 0;
61 
62  // Verifies the requested size
63  if(img.height() != height)
64  img = img.scaledToHeight(height, Qt::SmoothTransformation);
65 
66  width = img.width();
67 
68  // Converts QImage to te::color::RGBA**
70 
71  return rgba;
72 }
te::color::RGBAColor ** render(const te::se::ExternalGraphic *eg, std::size_t height, std::size_t &width)
It generates the image pattern from the given Symbology Enconding External Graphic element...
const te::xl::SimpleLink * getOnlineResource() const
The ExternalGraphic allows a reference to be made to an external graphic file with a Web URL or to in...
TEQTWIDGETSEXPORT QImage * GetImage(te::color::RGBAColor **img, int width, int height)
It creates a QImage from an RGBA color array.
Definition: Utils.cpp:69
A concrete renderer based on Qt4 for conversion of Symbology Enconding External Graphic elements to a...
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57