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 
37 {
38 }
39 
41 
43 {
44  /* For while this method only looks for URI on OnlineResource
45  and consider that the URI references a local image file. (Uba, Feb 2013) */
46 
48  if(link == nullptr)
49  return nullptr;
50 
51  const std::string uri = link->getHref();
52  if(uri.empty())
53  return nullptr;
54 
55  // Try load the image
56  QImage img;
57  if(!img.load(uri.c_str()))
58  return nullptr;
59 
60  // Verifies the requested size
61  if(img.height() != static_cast<int>(height))
62  img = img.scaledToHeight(static_cast<int>(height), Qt::SmoothTransformation);
63 
64  width = static_cast<size_t>(img.width());
65 
66  // Converts QImage to te::color::RGBA**
68 
69  return rgba;
70 }
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...
who udp maintains data bases showing who s shell tcp cmd syslog udp printer tcp spooler printer udp spooler videotex tcp videotex videotex udp videotex talk tcp like tenex link
TEQTWIDGETSEXPORT QImage * GetImage(te::color::RGBAColor **img, int width, int height)
It creates a QImage from an RGBA color array.
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