OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimGeoAnnotationBitmap.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // License: LGPL
5 //
6 // See LICENSE.txt file in the top level directory for more details.
7 //
8 // Author: Garrett Potts
9 //
10 //*************************************************************************
11 // $Id: ossimGeoAnnotationBitmap.cpp 22519 2013-12-16 15:18:29Z dburken $
12 
17 #include <ossim/base/ossimIrect.h>
18 
20  "ossimGeoAnnotationBitmap",
22 
24  const ossimGpt& center,
26  unsigned char r,
27  unsigned char g,
28  unsigned char b)
29  :ossimGeoAnnotationObject(r, g, b),
30  theCenterPoint(center),
31  theProjectedPoint(0,0),
32  theImageData(NULL)
33 {
34  if(imageData.valid() &&
35  (imageData->getScalarType()==OSSIM_UCHAR))
36  {
37  theImageData = imageData;
38  }
39  else
40  {
42  << "ossimGeoAnnotationBitmap::ossimGeoAnnotationBitmap\n"
43  << "Invalid image data passed to ossimGeoAnnotationBitmap "
44  << "constructor" << endl;
45  }
46 }
47 
49  const ossimGeoAnnotationBitmap& rhs)
50  :
52  theCenterPoint(rhs.theCenterPoint),
53  theProjectedPoint(rhs.theProjectedPoint),
54  theImageData(rhs.theImageData)
55 {
56 }
57 
59 {
60 }
61 
63 {
64  return new ossimGeoAnnotationBitmap(*this);
65 }
66 
68 {
69  if(theImageData.valid())
70  {
72  }
73 
74  return false;
75 }
76 
78  const ossimDrect& /* rect */)const
79 {
81 
83  << "ossimGeoAnnotationBitmap::getNewClippedObject WRNING: "
84  << "not implemented" << std::endl;
85 
86  return result;
87 }
88 
89 void ossimGeoAnnotationBitmap::applyScale(double /* x */, double /* y */)
90 {
92  << "ossimGeoAnnotationBitmap::applyScale WRNING: not implemented"
93  << std::endl;
94 }
95 
96 
98 {
99  out << "center: " << theCenterPoint << endl;
100  return out;
101 }
102 
104 {
105  ossimRefPtr<ossimImageData> destination = anImage.getImageData();
106 
107  if(!destination)
108  {
110  << "ossimGeoAnnotationBitmap::draw\n"
111  << "ERROR: can't draw annotation bitmap to NULL buffer" << endl;
112 
113  return;
114  }
115  ossimIrect destinationRect = destination->getImageRectangle();
117  if(!srcRect.intersects(destinationRect))
118  {
119  return;
120  }
121  ossimIrect clipRect = srcRect.clipToRect(destinationRect);
122 
123  long clipHeight = (long)clipRect.height();
124  long clipWidth = (long)clipRect.width();
125 
126 
127  if(clipRect.width() != 1.0 &&
128  clipRect.height() != 1.0)
129  {
130  long destinationOffset = (long)(((clipRect.ul().y - destinationRect.ul().y)* destinationRect.width()) +
131  (clipRect.ul().x - destinationRect.ul().x));
132  long srcOffset = (long)(((clipRect.ul().y - srcRect.ul().y)*srcRect.width()) +
133  (clipRect.ul().x - srcRect.ul().x));
134  long destinationIndex = destinationOffset;
135  long srcIndex = srcOffset;
136  long num_bands = destination->getNumberOfBands();
137  ossim_int32 s_width = (ossim_int32)srcRect.width();
138  ossim_int32 d_width = (ossim_int32)destinationRect.width();
139 
140  num_bands = num_bands > 3? 3:num_bands;
141 
142  const ossim_uint8* imageDataBuf = static_cast<const ossim_uint8*>(theImageData->getBuf());
143  unsigned char colorArray[3];
144  colorArray[0] = theRed;
145  colorArray[1] = theGreen;
146  colorArray[2] = theBlue;
147  for (long band=0; band<num_bands; ++band)
148  {
149  ossim_uint8* destinationBand = static_cast<ossim_uint8*>(destination->getBuf(band));
150  destinationIndex = destinationOffset;
151  srcIndex = srcOffset;
152  for(long line = 0; line < clipHeight; ++line)
153  {
154  for(long col = 0; col < clipWidth; ++col)
155  {
156  if(imageDataBuf[srcIndex + col])
157  {
158  destinationBand[destinationIndex + col] = colorArray[band];
159  }
160  }
161  srcIndex += s_width;
162  destinationIndex += d_width;
163  }
164  }
165  }
166 }
167 
169 {
170  rect = ossimDrect(0,0,0,0);
171 
172  if(theImageData.valid())
173  {
175  }
176 }
177 
179 {
180  if(projection)
181  {
184  if(theImageData.valid())
185  {
188 
189  theImageData->setOrigin(origin);
190  }
191  }
192 }
193 
195  ossimRefPtr<ossimImageData>& imageData)
196 {
197  theImageData = imageData;
198 }
199 
201 {
202  // nothing to be done since we don't support
203  // rotated bitmaps yet.
204 }
virtual ossim_uint32 getWidth() const
virtual ossimGeoAnnotationBitmap * getNewClippedObject(const ossimDrect &rect) const
virtual void applyScale(double x, double y)
virtual ossim_uint32 getNumberOfBands() const
bool valid() const
Definition: ossimRefPtr.h:75
virtual void draw(ossimRgbImage &anImage) const
double y
Definition: ossimDpt.h:165
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
virtual ossim_uint32 getHeight() const
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
RTTI_DEF1(ossimGeoAnnotationBitmap, "ossimGeoAnnotationBitmap", ossimGeoAnnotationObject) ossimGeoAnnotationBitmap
virtual bool intersects(const ossimDrect &rect) const
virtual ossimDrect getBoundingRect() const
ossimRefPtr< ossimImageData > getImageData()
Will return the image data.
virtual ossimIrect getImageRectangle() const
virtual void transform(ossimImageGeometry *projection)
ossimGeoAnnotationBitmap(const ossimGpt &center=ossimGpt(0, 0, 0), ossimRefPtr< ossimImageData > imageData=0, unsigned char r=255, unsigned char g=255, unsigned char b=255)
virtual std::ostream & print(std::ostream &out) const
Generic print method.
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
virtual void setOrigin(const ossimIpt &origin)
virtual ossimScalarType getScalarType() const
virtual void setImageData(ossimRefPtr< ossimImageData > &imageData)
ossim_int32 y
Definition: ossimIpt.h:142
virtual const void * getBuf() const
ossimRefPtr< ossimImageData > theImageData
double x
Definition: ossimDpt.h:164
bool worldToLocal(const ossimGpt &world_pt, ossimDpt &local_pt) const
Exposes the 3D world-to-local image coordinate reverse projection.
ossim_int32 x
Definition: ossimIpt.h:141
virtual ossimObject * dup() const
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
8 bit unsigned iteger
int ossim_int32