OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ossimRgbImage Class Reference

#include <ossimRgbImage.h>

Inheritance diagram for ossimRgbImage:
ossimReferenced

Public Member Functions

 ossimRgbImage ()
 
 ossimRgbImage (ossimRefPtr< ossimImageData > &currentImageData)
 
virtual void createNewGrey (ossim_int32 width, ossim_int32 height)
 Will construct a new single band image data object. More...
 
virtual void createNewTrueColor (ossim_int32 width, ossim_int32 height)
 Will construct a new 3 band rgb data object. More...
 
virtual void initialize ()
 Will initilize any pre-computations that are needed. More...
 
void slowPlotPixel (ossim_int32 x, ossim_int32 y, ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
 This will plot a pixel and will do inside outside compares. More...
 
void fastPlotPixel (ossim_int32 x, ossim_int32 y, ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
 same thing as slowPlotPixel but without the inside outside compare More...
 
void setThickness (ossim_int32 thickness)
 All the drawing algorithms have thickness. More...
 
ossim_int32 getThickness () const
 
void setCurrentImageData (ossimRefPtr< ossimImageData > &imageData)
 Allows you to change the image data that this RgbImage object operates on. More...
 
ossimRefPtr< ossimImageDatagetImageData ()
 Will return the image data. More...
 
void drawFilledPolygon (const std::vector< ossimDpt > &p)
 We will cut and paste the code from drawFilledPolygon(ossimIpt *p, int n). More...
 
void drawFilledPolygon (const std::vector< ossimIpt > &p)
 We will cut and paste the code from drawFilledPolygon(ossimIpt *p, int n). More...
 
void drawFilledPolygon (ossimDpt *p, int n)
 This will draw a polygon and fill it with the specified color. More...
 
void drawFilledPolygon (ossimIpt *p, int n)
 This will draw a polygon and fill it with the specified color. More...
 
void drawArc (double cx, double cy, double w, double h, double s, double e)
 will draw an arc. More...
 
void drawArc (int cx, int cy, int w, int h, int s, int e)
 will draw an arc. More...
 
void drawFilledEllipse (int cx, int cy, int sminor, int smajor, double rot)
 Draws a filled ellipse. More...
 
void drawEllipse (int cx, int cy, int sminor, int smajor, double rot, bool drawAxes=false)
 Draws an ellipse. More...
 
void drawFilledArc (double cx, double cy, double w, double h, double s, double e)
 This will draw a filled arc. More...
 
void drawFilledArc (int cx, int cy, int w, int h, int s, int e)
 This will draw a filled arc. More...
 
void drawPolygon (const std::vector< ossimDpt > &p)
 
void drawPolygon (const std::vector< ossimIpt > &p)
 
void drawPolygon (ossimDpt *p, int n)
 Draws a polygon. More...
 
void drawPolygon (ossimIpt *p, int n)
 Draws a polygon. More...
 
void drawLine (double x1, double y1, double x2, double y2)
 About all the draw routines will call draw line. More...
 
void drawLine (int x1, int y1, int x2, int y2)
 About all the draw routines will call draw line. More...
 
void drawLine (const ossimIpt &start, const ossimIpt &end)
 About all the draw routines will call draw line. More...
 
void drawLine (const ossimDpt &start, const ossimDpt &end)
 About all the draw routines will call draw line. More...
 
void drawRectangle (double x1, double y1, double x2, double y2)
 Will draw a rectangle. More...
 
void drawRectangle (int x1, int y1, int x2, int y2)
 Will draw a rectangle. More...
 
void drawFilledRectangle (double x1, double y1, double x2, double y2)
 Will draw a filled rectangle with the current draw color. More...
 
void drawFilledRectangle (int x1, int y1, int x2, int y2)
 Will draw a filled rectangle with the current draw color. More...
 
void fill ()
 Will fill the entire data object with the specified color set in setDrawColor. More...
 
void setDrawColor (ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255)
 
void getDrawColor (ossim_uint8 &rCurr, ossim_uint8 &gCurr, ossim_uint8 &bCurr)
 
const ossimRefPtr< ossimImageDatagetImageData () const
 Will take the point passed in and translate to a 0,0. More...
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Member Functions

virtual ~ossimRgbImage ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

ossimRefPtr< ossimImageDatatheImageData
 This object operates on the ossimImageData. More...
 
ossim_int32theOffsets
 This will hold precomputed offsets to the start of each row. More...
 
ossim_uint8theBands [3]
 This is a fast access to the start of each band. More...
 
ossim_int32 theWidth
 This is here so we don't have to call theWidth and theHeight of the ossimImageData. More...
 
ossim_int32 theHeight
 This is here so we don't have to call theWidth and theHeight of the ossimImageData. More...
 
ossim_int32 theThickness
 Holds the draw thickness. More...
 
ossim_uint8 theRed
 The red component of the color used in drawing the shapes. More...
 
ossim_uint8 theGreen
 The green component of the color used in drawing the shapes. More...
 
ossim_uint8 theBlue
 The blue component of the color used in drawing the shapes. More...
 

Detailed Description

Definition at line 18 of file ossimRgbImage.h.

Constructor & Destructor Documentation

◆ ossimRgbImage() [1/2]

ossimRgbImage::ossimRgbImage ( )

Definition at line 799 of file ossimRgbImage.cpp.

800  : ossimReferenced(),
801  theImageData(0),
802  theOffsets(0),
803  theThickness(1),
804  theRed(255),
805  theGreen(255),
806  theBlue(255)
807 {
808 }
ossim_uint8 theGreen
The green component of the color used in drawing the shapes.
ossim_int32 theThickness
Holds the draw thickness.
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
ossim_uint8 theRed
The red component of the color used in drawing the shapes.
ossim_uint8 theBlue
The blue component of the color used in drawing the shapes.
ossim_int32 * theOffsets
This will hold precomputed offsets to the start of each row.

◆ ossimRgbImage() [2/2]

ossimRgbImage::ossimRgbImage ( ossimRefPtr< ossimImageData > &  currentImageData)
Parameters
currentImageDataThe tile to annotate or draw to.
Note
This can be any number of bands; however, will only draw to up to 3.

Definition at line 810 of file ossimRgbImage.cpp.

References setCurrentImageData().

811  : ossimReferenced(),
812  theImageData(0),
813  theOffsets(0),
814  theThickness(1),
815  theRed(255),
816  theGreen(255),
817  theBlue(255)
818 {
819  setCurrentImageData(currentImageData);
820 }
ossim_uint8 theGreen
The green component of the color used in drawing the shapes.
ossim_int32 theThickness
Holds the draw thickness.
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
ossim_uint8 theRed
The red component of the color used in drawing the shapes.
ossim_uint8 theBlue
The blue component of the color used in drawing the shapes.
ossim_int32 * theOffsets
This will hold precomputed offsets to the start of each row.
void setCurrentImageData(ossimRefPtr< ossimImageData > &imageData)
Allows you to change the image data that this RgbImage object operates on.

◆ ~ossimRgbImage()

ossimRgbImage::~ossimRgbImage ( )
protectedvirtual

Definition at line 823 of file ossimRgbImage.cpp.

References theOffsets.

824 {
825  if(theOffsets)
826  {
827  delete [] theOffsets;
828  theOffsets = 0;
829  }
830 }
ossim_int32 * theOffsets
This will hold precomputed offsets to the start of each row.

Member Function Documentation

◆ createNewGrey()

void ossimRgbImage::createNewGrey ( ossim_int32  width,
ossim_int32  height 
)
virtual

Will construct a new single band image data object.

Definition at line 837 of file ossimRgbImage.cpp.

References ossimImageData::initialize(), OSSIM_UCHAR, setCurrentImageData(), and theImageData.

838 {
840  OSSIM_UCHAR,
841  1,
842  width,
843  height);
845 
847 
848 }
virtual void initialize()
Initialize the data buffer.
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
void setCurrentImageData(ossimRefPtr< ossimImageData > &imageData)
Allows you to change the image data that this RgbImage object operates on.
8 bit unsigned iteger

◆ createNewTrueColor()

void ossimRgbImage::createNewTrueColor ( ossim_int32  width,
ossim_int32  height 
)
virtual

Will construct a new 3 band rgb data object.

Definition at line 850 of file ossimRgbImage.cpp.

References ossimImageData::initialize(), OSSIM_UCHAR, and theImageData.

851 {
853  OSSIM_UCHAR,
854  3,
855  width,
856  height);
858 }
virtual void initialize()
Initialize the data buffer.
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
8 bit unsigned iteger

◆ drawArc() [1/2]

void ossimRgbImage::drawArc ( double  cx,
double  cy,
double  w,
double  h,
double  s,
double  e 
)

will draw an arc.

The cx and cy specifies the center point in image space. The parameters w, h are the width and height of the arc. The s and e are the starting and ending angles. So if I want to draw a complete circle at point 45, 45 with width 10 and height 23 then we set the angles s =0 and e = 360: drawArc(45, 45, 10, 23, 0, 360).

Referenced by ossimAnnotationMultiEllipseObject::draw().

◆ drawArc() [2/2]

void ossimRgbImage::drawArc ( int  cx,
int  cy,
int  w,
int  h,
int  s,
int  e 
)

will draw an arc.

The cx and cy specifies the center point in image space. The parameters w, h are the width and height of the arc. The s and e are the starting and ending angles. So if I want to draw a complete circle at point 45, 45 with width 10 and height 23 then we set the angles s =0 and e = 360: drawArc(45, 45, 10, 23, 0, 360).

Definition at line 1103 of file ossimRgbImage.cpp.

References theImageData, x, and y.

1109 {
1110  if(!theImageData)
1111  {
1112  return;
1113  }
1114  int i;
1115  int lx = 0, ly = 0;
1116  // int fx, fy;
1117  int w2, h2;
1118  w2 = w / 2;
1119  h2 = h / 2;
1120  while (e < s)
1121  {
1122  e += 360;
1123  }
1124  for (i = s; (i <= e); i++)
1125  {
1126  int x, y;
1127  x = ((ossim_int32) gdCosT[i % 360] * (ossim_int32) w2 / 1024) + cx;
1128  y = ((ossim_int32) gdSinT[i % 360] * (ossim_int32) h2 / 1024) + cy;
1129  if (i != s)
1130  {
1131  drawLine (lx, ly, x, y);
1132  }
1133  // else
1134  // {
1135  // fx = x;
1136  // fy = y;
1137  // }
1138  lx = x;
1139  ly = y;
1140  }
1141 }
ossim_uint32 x
ossim_uint32 y
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
int ossim_int32

◆ drawEllipse()

void ossimRgbImage::drawEllipse ( int  cx,
int  cy,
int  sminor,
int  smajor,
double  rot,
bool  drawAxes = false 
)

Draws an ellipse.

Rot is the major axis rotation from up. rot (rotation is in radians).

Definition at line 1188 of file ossimRgbImage.cpp.

References theImageData, TWO_PI, and x.

Referenced by ossimAnnotationEllipseObject::draw().

1194 {
1195  if(!theImageData)
1196  {
1197  return;
1198  }
1199 
1200  // Range check rotation.
1201  if ( (rot < -TWO_PI) || (rot > TWO_PI) )
1202  {
1203  rot = 0.0; // throw exception or continue???
1204  }
1205 
1206  int lx = 0;
1207  int ly = 0;
1208  int w2 = axisMinor/2;
1209  int h2 = axisMajor/2;
1210 
1211  float sinRot = sin(rot);
1212  float cosRot = cos(rot);
1213 
1214  int xMaj[2];
1215  int yMaj[2];
1216  int xMin[2];
1217  int yMin[2];
1218  xMin[0] = 0;
1219  xMin[1] = 0;
1220  yMin[0] = 0;
1221  yMin[1] = 0;
1222  xMaj[0] = 0;
1223  xMaj[1] = 0;
1224  yMaj[0] = 0;
1225  yMaj[1] = 0;
1226 
1227  for (int i = 0; i <= 360; i++)
1228  {
1229  // Compute current coordinates
1230  int x = ((ossim_int32) gdCosT[i % 360] * (ossim_int32) w2 / 1024);
1231  int y = ((ossim_int32) gdSinT[i % 360] * (ossim_int32) h2 / 1024);
1232 
1233  // Rotate through orientation angle
1234  int rx = (ossim_int32)((float)x*cosRot - (float)y*sinRot + cx);
1235  int ry = (ossim_int32)((float)y*cosRot + (float)x*sinRot + cy);
1236 
1237  // Draw the 1-degree segment
1238  if (i != 0)
1239  {
1240  drawLine (lx, ly, rx, ry);
1241  }
1242  lx = rx;
1243  ly = ry;
1244 
1245  if (drawAxes)
1246  {
1247  // Save axes end-points
1248  switch (i)
1249  {
1250  case 0:
1251  xMin[0] = rx;
1252  yMin[0] = ry;
1253  break;
1254  case 90:
1255  xMaj[0] = rx;
1256  yMaj[0] = ry;
1257  break;
1258  case 180:
1259  xMin[1] = rx;
1260  yMin[1] = ry;
1261  break;
1262  case 270:
1263  xMaj[1] = rx;
1264  yMaj[1] = ry;
1265  break;
1266  default:
1267  break;
1268  }
1269  }
1270  }
1271 
1272  // Draw axes if selected
1273  if (drawAxes)
1274  {
1275  ossim_uint8 rCurr;
1276  ossim_uint8 gCurr;
1277  ossim_uint8 bCurr;
1278  getDrawColor(rCurr, gCurr, bCurr);
1279 
1280  ossim_int32 thickCurr = theThickness;
1281 
1282  ossim_uint8 mask = 0xff;
1283 
1284  // Draw the minor axis first so it is on the bottom.
1285  drawLine (xMin[0], yMin[0], xMin[1], yMin[1]);
1286 
1287  //set major axis to thicker yellow
1288  setDrawColor((rCurr^mask),(gCurr^mask),(bCurr^mask));
1289  // setDrawColor(255,255,1);
1290  theThickness += 1;
1291  drawLine (xMaj[0], yMaj[0], xMaj[1], yMaj[1]);
1292  theThickness = thickCurr;
1293  setDrawColor(rCurr,gCurr,bCurr); //set back
1294  }
1295 }
ossim_uint32 x
ossim_uint32 y
ossim_int32 theThickness
Holds the draw thickness.
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
void setDrawColor(ossim_uint8 r=255, ossim_uint8 g=255, ossim_uint8 b=255)
void getDrawColor(ossim_uint8 &rCurr, ossim_uint8 &gCurr, ossim_uint8 &bCurr)
#define TWO_PI
unsigned char ossim_uint8
int ossim_int32

◆ drawFilledArc() [1/2]

void ossimRgbImage::drawFilledArc ( double  cx,
double  cy,
double  w,
double  h,
double  s,
double  e 
)

This will draw a filled arc.

See drawArc for documentation of parameters.

Definition at line 1034 of file ossimRgbImage.cpp.

Referenced by ossimAnnotationMultiEllipseObject::draw().

1040 {
1041 // drawFilledArc((int)ossim::round<int>(cx), // center x
1042 // (int)ossim::round<int>(cy), // center y
1043 // (int)ossim::round<int>(w), // width
1044 // (int)ossim::round<int>(h), // height
1045 // (int)ossim::round<int>(s), // start angle
1046 // (int)ossim::round<int>(e)); // end angle
1047  drawFilledArc((int)(cx), // center x
1048  (int)(cy), // center y
1049  (int)(w), // width
1050  (int)(h), // height
1051  (int)(s), // start angle
1052  (int)(e)); // end angle
1053 }
void drawFilledArc(double cx, double cy, double w, double h, double s, double e)
This will draw a filled arc.

◆ drawFilledArc() [2/2]

void ossimRgbImage::drawFilledArc ( int  cx,
int  cy,
int  w,
int  h,
int  s,
int  e 
)

This will draw a filled arc.

See drawArc for documentation of parameters.

Definition at line 1055 of file ossimRgbImage.cpp.

References theImageData, x, and y.

1061 {
1062  if(!theImageData)
1063  {
1064  return;
1065  }
1066  ossimIpt pts[3];
1067  int i;
1068  int lx = 0, ly = 0;
1069  // int fx, fy;
1070  int w2, h2;
1071  w2 = w / 2;
1072  h2 = h / 2;
1073  while (e < s)
1074  {
1075  e += 360;
1076  }
1077  for (i = s; (i <= e); i++)
1078  {
1079  int x, y;
1080  x = ((ossim_int32) gdCosT[i % 360] * (ossim_int32) w2 / 1024) + cx;
1081  y = ((ossim_int32) gdSinT[i % 360] * (ossim_int32) h2 / 1024) + cy;
1082  if (i != s)
1083  {
1084  /* This is expensive! */
1085  pts[0].x = lx;
1086  pts[0].y = ly;
1087  pts[1].x = x;
1088  pts[1].y = y;
1089  pts[2].x = cx;
1090  pts[2].y = cy;
1091  drawFilledPolygon (pts, 3);
1092  }
1093  // else
1094  // {
1095  // fx = x;
1096  // fy = y;
1097  // }
1098  lx = x;
1099  ly = y;
1100  }
1101 }
ossim_uint32 x
ossim_uint32 y
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
void drawFilledPolygon(const std::vector< ossimDpt > &p)
We will cut and paste the code from drawFilledPolygon(ossimIpt *p, int n).
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ drawFilledEllipse()

void ossimRgbImage::drawFilledEllipse ( int  cx,
int  cy,
int  sminor,
int  smajor,
double  rot 
)

Draws a filled ellipse.

Rot is the major axis rotation from up. rot (rotaition) is in radians.

Definition at line 1143 of file ossimRgbImage.cpp.

References theImageData, and x.

Referenced by ossimAnnotationEllipseObject::draw().

1148 {
1149  if(!theImageData)
1150  {
1151  return;
1152  }
1153 
1154  int lx = 0;
1155  int ly = 0;
1156  int w2 = axisMinor/2;
1157  int h2 = axisMajor/2;
1158  ossimIpt pts[3];
1159 
1160  float sinRot = sin(rot);
1161  float cosRot = cos(rot);
1162 
1163  for (int i = 0; i <= 360; ++i)
1164  {
1165  int x = ((ossim_int32) gdCosT[i % 360] * (ossim_int32) w2 / 1024);
1166  int y = ((ossim_int32) gdSinT[i % 360] * (ossim_int32) h2 / 1024);
1167 
1168  int rx = (ossim_int32)((float)x*cosRot - (float)y*sinRot + cx);
1169  int ry = (ossim_int32)((float)y*cosRot + (float)x*sinRot + cy);
1170 
1171  if (i != 0)
1172  {
1173  /* This is expensive! */
1174  pts[0].x = lx;
1175  pts[0].y = ly;
1176  pts[1].x = rx;
1177  pts[1].y = ry;
1178  pts[2].x = cx;
1179  pts[2].y = cy;
1180 
1181  drawFilledPolygon (pts, 3);
1182  }
1183  lx = rx;
1184  ly = ry;
1185  }
1186 }
ossim_uint32 x
ossim_uint32 y
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
void drawFilledPolygon(const std::vector< ossimDpt > &p)
We will cut and paste the code from drawFilledPolygon(ossimIpt *p, int n).
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ drawFilledPolygon() [1/4]

void ossimRgbImage::drawFilledPolygon ( const std::vector< ossimDpt > &  p)

We will cut and paste the code from drawFilledPolygon(ossimIpt *p, int n).

Definition at line 1586 of file ossimRgbImage.cpp.

References drawLine(), gdCompareInt(), n, theImageData, x, and y.

Referenced by ossimAnnotationMultiPolyObject::draw(), and ossimAnnotationPolyObject::draw().

1587 {
1588  if(!theImageData)
1589  {
1590  return;
1591  }
1592  int n = (int)p.size();
1593  int i;
1594  int y;
1595  int miny, maxy;
1596  int x1, y1;
1597  int x2, y2;
1598  int ind1, ind2;
1599  int ints;
1600  int *polyInts = 0;
1601 
1602  if(!n)
1603  {
1604  return;
1605  }
1606  polyInts = new int[n];
1607 
1608  miny = (int)p[0].y;//ossim::round<int>(p[0].y);
1609  maxy = (int)p[0].y;//ossim::round<int>(p[0].y);
1610  for (i = 1; (i < n); i++)
1611  {
1612  int testPy = (int)p[i].y;//ossim::round<int>(p[i].y);
1613  if (testPy < miny)
1614  {
1615  miny = testPy;
1616  }
1617  if (testPy > maxy)
1618  {
1619  maxy = testPy;
1620  }
1621  }
1622  /* Fix in 1.3: count a vertex only once */
1623  for (y = miny; (y <= maxy); y++)
1624  {
1625  ints = 0;
1626  for (i = 0; (i < n); i++)
1627  {
1628  if (!i)
1629  {
1630  ind1 = n - 1;
1631  ind2 = 0;
1632  }
1633  else
1634  {
1635  ind1 = i - 1;
1636  ind2 = i;
1637  }
1638 // y1 = ossim::round<int>(p[ind1].y);
1639 // y2 = ossim::round<int>(p[ind2].y);
1640  y1 = (int)(p[ind1].y);
1641  y2 = (int)(p[ind2].y);
1642  if (y1 < y2)
1643  {
1644 // x1 = ossim::round<int>(p[ind1].x);
1645 // x2 = ossim::round<int>(p[ind2].x);
1646  x1 = (int)(p[ind1].x);
1647  x2 = (int)(p[ind2].x);
1648  }
1649  else if (y1 > y2)
1650  {
1651 // y2 = ossim::round<int>(p[ind1].y);
1652 // y1 = ossim::round<int>(p[ind2].y);
1653 // x2 = ossim::round<int>(p[ind1].x);
1654 // x1 = ossim::round<int>(p[ind2].x);
1655  y2 = (int)(p[ind1].y);
1656  y1 = (int)(p[ind2].y);
1657  x2 = (int)(p[ind1].x);
1658  x1 = (int)(p[ind2].x);
1659  }
1660  else
1661  {
1662  continue;
1663  }
1664  if ((y >= y1) && (y < y2))
1665  {
1666  polyInts[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1;
1667  }
1668  else if ((y == maxy) && (y > y1) && (y <= y2))
1669  {
1670  polyInts[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1;
1671  }
1672  }
1673  qsort (polyInts, ints, sizeof (int), gdCompareInt);
1674 
1675  for (i = 0; (i < (ints)); i += 2)
1676  {
1677  drawLine (polyInts[i], y,
1678  polyInts[i + 1], y);
1679  }
1680  }
1681 
1682  if (polyInts) delete [] polyInts;
1683 }
ossim_uint32 x
ossim_uint32 y
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
os2<< "> n<< " > nendobj n
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
int gdCompareInt(const void *a, const void *b)

◆ drawFilledPolygon() [2/4]

void ossimRgbImage::drawFilledPolygon ( const std::vector< ossimIpt > &  p)

We will cut and paste the code from drawFilledPolygon(ossimIpt *p, int n).

Definition at line 1496 of file ossimRgbImage.cpp.

References drawLine(), gdCompareInt(), n, theImageData, and y.

1497 {
1498  if(!theImageData)
1499  {
1500  return;
1501  }
1502  int n = (int)p.size();
1503  int i;
1504  int y;
1505  int miny, maxy;
1506  int x1, y1;
1507  int x2, y2;
1508  int ind1, ind2;
1509  int ints;
1510  int *polyInts = 0;
1511 
1512  if(!n)
1513  {
1514  return;
1515  }
1516  polyInts = new int[n];
1517 
1518  miny = p[0].y;
1519  maxy = p[0].y;
1520  for (i = 1; (i < n); i++)
1521  {
1522  if (p[i].y < miny)
1523  {
1524  miny = p[i].y;
1525  }
1526  if (p[i].y > maxy)
1527  {
1528  maxy = p[i].y;
1529  }
1530  }
1531  /* Fix in 1.3: count a vertex only once */
1532  for (y = miny; (y <= maxy); y++)
1533  {
1534  ints = 0;
1535  for (i = 0; (i < n); i++)
1536  {
1537  if (!i)
1538  {
1539  ind1 = n - 1;
1540  ind2 = 0;
1541  }
1542  else
1543  {
1544  ind1 = i - 1;
1545  ind2 = i;
1546  }
1547  y1 = p[ind1].y;
1548  y2 = p[ind2].y;
1549  if (y1 < y2)
1550  {
1551  x1 = p[ind1].x;
1552  x2 = p[ind2].x;
1553  }
1554  else if (y1 > y2)
1555  {
1556  y2 = p[ind1].y;
1557  y1 = p[ind2].y;
1558  x2 = p[ind1].x;
1559  x1 = p[ind2].x;
1560  }
1561  else
1562  {
1563  continue;
1564  }
1565  if ((y >= y1) && (y < y2))
1566  {
1567  polyInts[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1;
1568  }
1569  else if ((y == maxy) && (y > y1) && (y <= y2))
1570  {
1571  polyInts[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1;
1572  }
1573  }
1574  qsort (polyInts, ints, sizeof (int), gdCompareInt);
1575 
1576  for (i = 0; (i < (ints)); i += 2)
1577  {
1578  drawLine (polyInts[i], y,
1579  polyInts[i + 1], y);
1580  }
1581  }
1582 
1583  if (polyInts) delete [] polyInts;
1584 }
ossim_uint32 y
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
os2<< "> n<< " > nendobj n
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
int gdCompareInt(const void *a, const void *b)

◆ drawFilledPolygon() [3/4]

void ossimRgbImage::drawFilledPolygon ( ossimDpt p,
int  n 
)

This will draw a polygon and fill it with the specified color.

Definition at line 1396 of file ossimRgbImage.cpp.

References drawLine(), gdCompareInt(), n, theImageData, ossimDpt::x, x, and y.

1398 {
1399  if(!theImageData)
1400  {
1401  return;
1402  }
1403  int i;
1404  int y;
1405  int miny, maxy;
1406  int x1, y1;
1407  int x2, y2;
1408  int ind1, ind2;
1409  int ints;
1410  int *polyInts = 0;
1411 
1412  if(!n)
1413  {
1414  return;
1415  }
1416  polyInts = new int[n];
1417 
1418 // miny = ossim::round<int>(p[0].y);
1419 // maxy = ossim::round<int>(p[0].y);
1420  miny = (int)(p[0].y);
1421  maxy = (int)(p[0].y);
1422  for (i = 1; (i < n); i++)
1423  {
1424 // int testPy = ossim::round<int>(p[i].y);
1425  int testPy = (int)(p[i].y);
1426  if (testPy < miny)
1427  {
1428  miny = testPy;
1429  }
1430  if (testPy > maxy)
1431  {
1432  maxy = testPy;
1433  }
1434  }
1435  /* Fix in 1.3: count a vertex only once */
1436  for (y = miny; (y <= maxy); y++)
1437  {
1438  ints = 0;
1439  for (i = 0; (i < n); i++)
1440  {
1441  if (!i)
1442  {
1443  ind1 = n - 1;
1444  ind2 = 0;
1445  }
1446  else
1447  {
1448  ind1 = i - 1;
1449  ind2 = i;
1450  }
1451 // y1 = ossim::round<int>(p[ind1].y);
1452 // y2 = ossim::round<int>(p[ind2].y);
1453  y1 = (int)(p[ind1].y);
1454  y2 = (int)(p[ind2].y);
1455  if (y1 < y2)
1456  {
1457  x1 = ossim::round<int>(p[ind1].x);
1458  x2 = ossim::round<int>(p[ind2].x);
1459  }
1460  else if (y1 > y2)
1461  {
1462 // y2 = ossim::round<int>(p[ind1].y);
1463 // y1 = ossim::round<int>(p[ind2].y);
1464 // x2 = ossim::round<int>(p[ind1].x);
1465 // x1 = ossim::round<int>(p[ind2].x);
1466  y2 = (int)(p[ind1].y);
1467  y1 = (int)(p[ind2].y);
1468  x2 = (int)(p[ind1].x);
1469  x1 = (int)(p[ind2].x);
1470  }
1471  else
1472  {
1473  continue;
1474  }
1475  if ((y >= y1) && (y < y2))
1476  {
1477  polyInts[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1;
1478  }
1479  else if ((y == maxy) && (y > y1) && (y <= y2))
1480  {
1481  polyInts[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1;
1482  }
1483  }
1484  qsort (polyInts, ints, sizeof (int), gdCompareInt);
1485 
1486  for (i = 0; (i < (ints)); i += 2)
1487  {
1488  drawLine (polyInts[i], y,
1489  polyInts[i + 1], y);
1490  }
1491  }
1492 
1493  if (polyInts) delete [] polyInts;
1494 }
ossim_uint32 x
ossim_uint32 y
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
os2<< "> n<< " > nendobj n
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
int gdCompareInt(const void *a, const void *b)
double x
Definition: ossimDpt.h:164

◆ drawFilledPolygon() [4/4]

void ossimRgbImage::drawFilledPolygon ( ossimIpt p,
int  n 
)

This will draw a polygon and fill it with the specified color.

Definition at line 1297 of file ossimRgbImage.cpp.

References drawLine(), gdCompareInt(), max, min, n, theImageData, ossimIpt::x, x, ossimIpt::y, and y.

1299 {
1300  if(!theImageData)
1301  {
1302  return;
1303  }
1304  int i;
1305  int y;
1306  int miny, maxy;
1307  int minx, maxx;
1308  int x1, y1;
1309  int x2, y2;
1310  int ind1, ind2;
1311  int ints;
1312  int *polyInts = 0;
1313 
1314  if(!n)
1315  {
1316  return;
1317  }
1318  polyInts = new int[n];
1319 
1320  miny = p[0].y;
1321  maxy = p[0].y;
1322  minx = p[0].x;
1323  maxx = p[0].x;
1324  for (i = 1; (i < n); i++)
1325  {
1326  miny = std::min((int)p[i].y, miny);
1327  minx = std::min((int)p[i].x, minx);
1328  maxy = std::max((int)p[i].y, maxy);
1329  maxx = std::max((int)p[i].x, maxx);
1330  }
1331  /* Fix in 1.3: count a vertex only once */
1332  for (y = miny; (y <= maxy); y++)
1333  {
1334  ints = 0;
1335  for (i = 0; (i < n); i++)
1336  {
1337  if (!i)
1338  {
1339  ind1 = n - 1;
1340  ind2 = 0;
1341  }
1342  else
1343  {
1344  ind1 = i - 1;
1345  ind2 = i;
1346  }
1347  y1 = p[ind1].y;
1348  y2 = p[ind2].y;
1349  if (y1 < y2)
1350  {
1351  x1 = p[ind1].x;
1352  x2 = p[ind2].x;
1353  }
1354  else if (y1 > y2)
1355  {
1356  y2 = p[ind1].y;
1357  y1 = p[ind2].y;
1358  x2 = p[ind1].x;
1359  x1 = p[ind2].x;
1360  }
1361  else
1362  {
1363  continue;
1364  }
1365  if ((y >= y1) && (y < y2))
1366  {
1367  polyInts[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1;
1368  }
1369  else if ((y == maxy) && (y > y1) && (y <= y2))
1370  {
1371  polyInts[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1;
1372  }
1373  }
1374  qsort (polyInts, ints, sizeof (int), gdCompareInt);
1375 
1376  if(ints)
1377  {
1378  for (i = 0; (i < (ints)); i += 2)
1379  {
1380  drawLine (polyInts[i], y,
1381  polyInts[i + 1], y);
1382  }
1383  }
1384  else
1385  {
1386  if((miny == maxy) && (minx==maxx))
1387  {
1388  drawLine((int)p[0].x, (int)p[0].y, (int)p[0].x, (int)p[0].y);
1389  }
1390  }
1391  }
1392 
1393  if (polyInts) delete [] polyInts;
1394 }
ossim_uint32 x
ossim_uint32 y
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
os2<< "> n<< " > nendobj n
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
int gdCompareInt(const void *a, const void *b)
#define max(a, b)
Definition: auxiliary.h:76
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
#define min(a, b)
Definition: auxiliary.h:75

◆ drawFilledRectangle() [1/2]

void ossimRgbImage::drawFilledRectangle ( double  x1,
double  y1,
double  x2,
double  y2 
)

Will draw a filled rectangle with the current draw color.

Use setDrawColor to set it.

Definition at line 1995 of file ossimRgbImage.cpp.

1999 {
2000 // drawFilledRectangle((int)ossim::round<int>(x1),
2001 // (int)ossim::round<int>(y1),
2002 // (int)ossim::round<int>(x2),
2003 // (int)ossim::round<int>(y2));
2004  drawFilledRectangle((int)(x1),
2005  (int)(y1),
2006  (int)(x2),
2007  (int)(y2));
2008 }
void drawFilledRectangle(double x1, double y1, double x2, double y2)
Will draw a filled rectangle with the current draw color.

◆ drawFilledRectangle() [2/2]

void ossimRgbImage::drawFilledRectangle ( int  x1,
int  y1,
int  x2,
int  y2 
)

Will draw a filled rectangle with the current draw color.

Use setDrawColor to set it.

Definition at line 2010 of file ossimRgbImage.cpp.

References slowPlotPixel(), theBlue, theGreen, theRed, x, and y.

2014 {
2015  int x, y;
2016 
2017  if(x1 > x2)
2018  {
2019  swap(x1, x2);
2020  }
2021  if(y1 > y2)
2022  {
2023  swap(y1, y2);
2024  }
2025  for (y = y1; (y <= y2); y++)
2026  {
2027  for (x = x1; (x <= x2); x++)
2028  {
2030  }
2031  }
2032 }
ossim_uint32 x
ossim_uint8 theGreen
The green component of the color used in drawing the shapes.
ossim_uint32 y
void slowPlotPixel(ossim_int32 x, ossim_int32 y, ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
This will plot a pixel and will do inside outside compares.
ossim_uint8 theRed
The red component of the color used in drawing the shapes.
ossim_uint8 theBlue
The blue component of the color used in drawing the shapes.

◆ drawLine() [1/4]

void ossimRgbImage::drawLine ( double  x1,
double  y1,
double  x2,
double  y2 
)

About all the draw routines will call draw line.

it takes a start and an end point and a color value. theColor used is set by the setDrawColor.

Definition at line 1710 of file ossimRgbImage.cpp.

Referenced by ossimAnnotationMultiPolyLineObject::draw(), ossimAnnotationMultiPolyObject::draw(), ossimAnnotationPolyObject::draw(), ossimAnnotationLineObject::draw(), ossimAnnotationMultiLineObject::draw(), drawFilledPolygon(), drawLine(), drawPolygon(), and drawRectangle().

1714 {
1715 // drawLine((int)ossim::round<int>(x1),
1716 // (int)ossim::round<int>(y1),
1717 // (int)ossim::round<int>(x2),
1718 // (int)ossim::round<int>(y2));
1719  drawLine((int)(x1),
1720  (int)(y1),
1721  (int)(x2),
1722  (int)(y2));
1723 
1724 }
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.

◆ drawLine() [2/4]

void ossimRgbImage::drawLine ( int  x1,
int  y1,
int  x2,
int  y2 
)

About all the draw routines will call draw line.

it takes a start and an end point and a color value. theColor used is set by the setDrawColor.

Definition at line 1725 of file ossimRgbImage.cpp.

References abs, ossimImageData::getOrigin(), slowPlotPixel(), theBlue, theGreen, theImageData, theRed, theThickness, ossimIpt::x, x, ossimIpt::y, and y.

1729 {
1730  if(!theImageData)
1731  {
1732  return;
1733  }
1734 
1735  // we need to shift x and y relative to the image data
1736  // origin. That way we are doing the algorithm relative to
1737  // the 0,0
1738  //
1739  ossimIpt origin = ossimDpt(theImageData->getOrigin());
1740  x1 += (-origin.x);
1741  y1 += (-origin.y);
1742  x2 += (-origin.x);
1743  y2 += (-origin.y);
1744 
1745 // ossimDpt start(x1, y1);
1746 // ossimDpt end(x2,y2);
1747 // ossimDrect bounds(0,0,theWidth-1, theHeight-1);
1748 
1749 // if(bounds.clip(start, end)) return;
1750 
1751 // x1 = (int)start.x;
1752 // y1 = (int)start.y;
1753 // x2 = (int)end.x;
1754 // y2 = (int)end.y;
1755 
1756  int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
1757  int wid;
1758  int w, wstart;
1759  int thick = theThickness;
1760 
1761  dx = abs (x2 - x1);
1762  dy = abs (y2 - y1);
1763  if (dy <= dx)
1764  {
1765  /* More-or-less horizontal. use wid for vertical stroke */
1766  /* Doug Claar: watch out for NaN in atan2 (2.0.5) */
1767  if ((dx == 0) && (dy == 0))
1768  {
1769  wid = 1;
1770  }
1771  else
1772  {
1773  /* 2.0.12: Michael Schwartz: divide rather than multiply;
1774  TBB: but watch out for /0! */
1775  double ac = cos (atan2 ((double)dy, (double)dx));
1776  if (ac != 0)
1777  {
1778  wid = ossim::round<int>(thick / ac);
1779  }
1780  else
1781  {
1782  wid = 1;
1783  }
1784  if (wid == 0)
1785  {
1786  wid = 1;
1787  }
1788  }
1789  d = 2 * dy - dx;
1790  incr1 = 2 * dy;
1791  incr2 = 2 * (dy - dx);
1792  if (x1 > x2)
1793  {
1794  x = x2;
1795  y = y2;
1796  ydirflag = (-1);
1797  xend = x1;
1798  }
1799  else
1800  {
1801  x = x1;
1802  y = y1;
1803  ydirflag = 1;
1804  xend = x2;
1805  }
1806 
1807  /* Set up line thickness */
1808  wstart = y - wid / 2;
1809  for (w = wstart; w < wstart + wid; w++)
1811 
1812  if (((y2 - y1) * ydirflag) > 0)
1813  {
1814  while (x < xend)
1815  {
1816  x++;
1817  if (d < 0)
1818  {
1819  d += incr1;
1820  }
1821  else
1822  {
1823  y++;
1824  d += incr2;
1825  }
1826  wstart = y - wid / 2;
1827  for (w = wstart; w < wstart + wid; w++)
1829  }
1830  }
1831  else
1832  {
1833  while (x < xend)
1834  {
1835  x++;
1836  if (d < 0)
1837  {
1838  d += incr1;
1839  }
1840  else
1841  {
1842  y--;
1843  d += incr2;
1844  }
1845  wstart = y - wid / 2;
1846  for (w = wstart; w < wstart + wid; w++)
1848  }
1849  }
1850  }
1851  else
1852  {
1853  /* More-or-less vertical. use wid for horizontal stroke */
1854  /* 2.0.12: Michael Schwartz: divide rather than multiply;
1855  TBB: but watch out for /0! */
1856  double as = sin (atan2 ((double)dy, (double)dx));
1857  if (as != 0)
1858  {
1859  wid = ossim::round<int>(thick / as);
1860  }
1861  else
1862  {
1863  wid = 1;
1864  }
1865  if (wid == 0)
1866  wid = 1;
1867 
1868  d = 2 * dx - dy;
1869  incr1 = 2 * dx;
1870  incr2 = 2 * (dx - dy);
1871  if (y1 > y2)
1872  {
1873  y = y2;
1874  x = x2;
1875  yend = y1;
1876  xdirflag = (-1);
1877  }
1878  else
1879  {
1880  y = y1;
1881  x = x1;
1882  yend = y2;
1883  xdirflag = 1;
1884  }
1885 
1886  /* Set up line thickness */
1887  wstart = x - wid / 2;
1888  for (w = wstart; w < wstart + wid; w++)
1890 
1891  if (((x2 - x1) * xdirflag) > 0)
1892  {
1893  while (y < yend)
1894  {
1895  y++;
1896  if (d < 0)
1897  {
1898  d += incr1;
1899  }
1900  else
1901  {
1902  x++;
1903  d += incr2;
1904  }
1905  wstart = x - wid / 2;
1906  for (w = wstart; w < wstart + wid; w++)
1908  }
1909  }
1910  else
1911  {
1912  while (y < yend)
1913  {
1914  y++;
1915  if (d < 0)
1916  {
1917  d += incr1;
1918  }
1919  else
1920  {
1921  x--;
1922  d += incr2;
1923  }
1924  wstart = x - wid / 2;
1925  for (w = wstart; w < wstart + wid; w++)
1927  }
1928  }
1929  }
1930 }
ossim_uint32 x
ossim_uint8 theGreen
The green component of the color used in drawing the shapes.
ossim_uint32 y
#define abs(a)
Definition: auxiliary.h:74
ossim_int32 theThickness
Holds the draw thickness.
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
void slowPlotPixel(ossim_int32 x, ossim_int32 y, ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
This will plot a pixel and will do inside outside compares.
ossim_uint8 theRed
The red component of the color used in drawing the shapes.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_uint8 theBlue
The blue component of the color used in drawing the shapes.
ossim_int32 x
Definition: ossimIpt.h:141
virtual const ossimIpt & getOrigin() const

◆ drawLine() [3/4]

void ossimRgbImage::drawLine ( const ossimIpt start,
const ossimIpt end 
)

About all the draw routines will call draw line.

it takes a start and an end point and a color value. theColor used is set by the setDrawColor.

Definition at line 1685 of file ossimRgbImage.cpp.

References drawLine(), ossimIpt::x, and ossimIpt::y.

1687 {
1688  drawLine((int)start.x,
1689  (int)start.y,
1690  (int)end.x,
1691  (int)end.y);
1692 
1693 }
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141

◆ drawLine() [4/4]

void ossimRgbImage::drawLine ( const ossimDpt start,
const ossimDpt end 
)

About all the draw routines will call draw line.

it takes a start and an end point and a color value. theColor used is set by the setDrawColor.

Definition at line 1695 of file ossimRgbImage.cpp.

References drawLine(), ossimDpt::x, and ossimDpt::y.

1697 {
1698 // drawLine((int)ossim::round<int>(start.x),
1699 // (int)ossim::round<int>(start.y),
1700 // (int)ossim::round<int>(end.x),
1701 // (int)ossim::round<int>(end.y));
1702 
1703  drawLine((int)(start.x),
1704  (int)(start.y),
1705  (int)(end.x),
1706  (int)(end.y));
1707 
1708 }
double y
Definition: ossimDpt.h:165
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
double x
Definition: ossimDpt.h:164

◆ drawPolygon() [1/4]

void ossimRgbImage::drawPolygon ( const std::vector< ossimDpt > &  p)

Definition at line 1002 of file ossimRgbImage.cpp.

References drawLine(), n, theImageData, x, and y.

1003 {
1004  if(!theImageData)
1005  {
1006  return;
1007  }
1008  int n = (int)p.size();
1009 
1010  int i;
1011  double lx, ly;
1012 
1013  if (!n)
1014  {
1015  return;
1016  }
1017  lx = p[0].x;
1018  ly = p[0].y;
1019  drawLine (lx, ly, p[n - 1].x, p[n - 1].y);
1020 
1021  for (i = 1; (i < n); i++)
1022  {
1023  drawLine (lx, ly, p[i].x, p[i].y);
1024  lx = p[i].x;
1025  ly = p[i].y;
1026  }
1027 }
ossim_uint32 x
ossim_uint32 y
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
os2<< "> n<< " > nendobj n
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.

◆ drawPolygon() [2/4]

void ossimRgbImage::drawPolygon ( const std::vector< ossimIpt > &  p)

Definition at line 975 of file ossimRgbImage.cpp.

References drawLine(), n, theImageData, x, and y.

976 {
977  if(!theImageData)
978  {
979  return;
980  }
981  int n = (int)p.size();
982 
983  int i;
984  int lx, ly;
985 
986  if (!n)
987  {
988  return;
989  }
990  lx = p[0].x;
991  ly = p[0].y;
992  drawLine (lx, ly, p[n - 1].x, p[n - 1].y);
993 
994  for (i = 1; (i < n); i++)
995  {
996  drawLine (lx, ly, p[i].x, p[i].y);
997  lx = p[i].x;
998  ly = p[i].y;
999  }
1000 }
ossim_uint32 x
ossim_uint32 y
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
os2<< "> n<< " > nendobj n
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.

◆ drawPolygon() [3/4]

void ossimRgbImage::drawPolygon ( ossimDpt p,
int  n 
)

Draws a polygon.

The first argument is an array of points. The second argument is the number of points and the rest are the rgb color values. theColor used is set by the setDrawColor.

Definition at line 948 of file ossimRgbImage.cpp.

References drawLine(), n, theImageData, ossimDpt::x, x, ossimDpt::y, and y.

950 {
951  if(!theImageData)
952  {
953  return;
954  }
955  int i;
956  double lx, ly;
957 
958  if (!n)
959  {
960  return;
961  }
962  lx = p->x;
963  ly = p->y;
964  drawLine (lx, ly, p[n - 1].x, p[n - 1].y);
965 
966  for (i = 1; (i < n); i++)
967  {
968  p++;
969  drawLine (lx, ly, p->x, p->y);
970  lx = p->x;
971  ly = p->y;
972  }
973 }
ossim_uint32 x
ossim_uint32 y
double y
Definition: ossimDpt.h:165
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
os2<< "> n<< " > nendobj n
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
double x
Definition: ossimDpt.h:164

◆ drawPolygon() [4/4]

void ossimRgbImage::drawPolygon ( ossimIpt p,
int  n 
)

Draws a polygon.

The first argument is an array of points. The second argument is the number of points and the rest are the rgb color values. theColor used is set by the setDrawColor.

Definition at line 921 of file ossimRgbImage.cpp.

References drawLine(), n, theImageData, ossimIpt::x, x, ossimIpt::y, and y.

923 {
924  if(!theImageData)
925  {
926  return;
927  }
928  int i;
929  int lx, ly;
930 
931  if (!n)
932  {
933  return;
934  }
935  lx = p->x;
936  ly = p->y;
937  drawLine (lx, ly, p[n - 1].x, p[n - 1].y);
938 
939  for (i = 1; (i < n); i++)
940  {
941  p++;
942  drawLine (lx, ly, p->x, p->y);
943  lx = p->x;
944  ly = p->y;
945  }
946 }
ossim_uint32 x
ossim_uint32 y
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
os2<< "> n<< " > nendobj n
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141

◆ drawRectangle() [1/2]

void ossimRgbImage::drawRectangle ( double  x1,
double  y1,
double  x2,
double  y2 
)

Will draw a rectangle.

The color used is set by setDrawColor.

Definition at line 1931 of file ossimRgbImage.cpp.

1935 {
1936 // drawRectangle(ossim::round<int>(x1),
1937 // ossim::round<int>(y1),
1938 // ossim::round<int>(x2),
1939 // ossim::round<int>(y2));
1940  drawRectangle((int)(x1),
1941  (int)(y1),
1942  (int)(x2),
1943  (int)(y2));
1944 }
void drawRectangle(double x1, double y1, double x2, double y2)
Will draw a rectangle.

◆ drawRectangle() [2/2]

void ossimRgbImage::drawRectangle ( int  x1,
int  y1,
int  x2,
int  y2 
)

Will draw a rectangle.

The color used is set by setDrawColor.

Definition at line 1946 of file ossimRgbImage.cpp.

References drawLine(), and theThickness.

1950 {
1951  if(x1 > x2)
1952  {
1953  swap(x1, x2);
1954  }
1955  if(y1 > y2)
1956  {
1957  swap(y1, y2);
1958  }
1959  int x1h = x1,
1960  x1v = x1,
1961  y1h = y1,
1962  y1v = y1,
1963  x2h = x2,
1964  x2v = x2,
1965  y2h = y2,
1966  y2v = y2;
1967 
1968  int thick = theThickness;
1969 
1970 
1971  if (thick > 1)
1972  {
1973  int half = thick / 2;
1974  int half1 = thick - half;
1975 
1976  if (y1 < y2)
1977  {
1978  y1v = y1h - half;
1979  y2v = y2h + half1 - 1;
1980  }
1981  else
1982  {
1983  y1v = y1h + half1 - 1;
1984  y2v = y2h - half;
1985  }
1986  }
1987 
1988  drawLine (x1h, y1h, x2h, y1h);
1989  drawLine (x1h, y2h, x2h, y2h);
1990  drawLine (x1v, y1v, x1v, y2v);
1991  drawLine (x2v, y1v, x2v, y2v);
1992 }
ossim_int32 theThickness
Holds the draw thickness.
void drawLine(double x1, double y1, double x2, double y2)
About all the draw routines will call draw line.

◆ fastPlotPixel()

void ossimRgbImage::fastPlotPixel ( ossim_int32  x,
ossim_int32  y,
ossim_uint8  r,
ossim_uint8  g,
ossim_uint8  b 
)
inline

same thing as slowPlotPixel but without the inside outside compare

Definition at line 395 of file ossimRgbImage.h.

References theBands, theOffsets, x, and y.

Referenced by fill().

400 {
401  theBands[0][theOffsets[y]+x] = r;
402  theBands[1][theOffsets[y]+x] = g;
403  theBands[2][theOffsets[y]+x] = b;
404 }
ossim_uint32 x
ossim_uint32 y
ossim_uint8 * theBands[3]
This is a fast access to the start of each band.
ossim_int32 * theOffsets
This will hold precomputed offsets to the start of each row.

◆ fill()

void ossimRgbImage::fill ( )

Will fill the entire data object with the specified color set in setDrawColor.

Definition at line 2034 of file ossimRgbImage.cpp.

References fastPlotPixel(), theBlue, theGreen, theHeight, theImageData, theRed, and theWidth.

2035 {
2036  if(!theImageData)
2037  {
2038  return;
2039  }
2040  ossim_int32 width = theWidth;
2041  ossim_int32 height = theHeight;
2042 
2043  for(ossim_int32 row = 0; row < height; ++row)
2044  {
2045  for(ossim_int32 col = 0; col < width; ++col)
2046  {
2047  fastPlotPixel(col, row,
2048  theRed, theGreen, theBlue);
2049  }
2050  }
2051 }
ossim_uint8 theGreen
The green component of the color used in drawing the shapes.
ossim_int32 theWidth
This is here so we don&#39;t have to call theWidth and theHeight of the ossimImageData.
ossim_int32 theHeight
This is here so we don&#39;t have to call theWidth and theHeight of the ossimImageData.
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
ossim_uint8 theRed
The red component of the color used in drawing the shapes.
ossim_uint8 theBlue
The blue component of the color used in drawing the shapes.
void fastPlotPixel(ossim_int32 x, ossim_int32 y, ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
same thing as slowPlotPixel but without the inside outside compare
int ossim_int32

◆ getDrawColor()

void ossimRgbImage::getDrawColor ( ossim_uint8 rCurr,
ossim_uint8 gCurr,
ossim_uint8 bCurr 
)

Definition at line 2062 of file ossimRgbImage.cpp.

References theBlue, theGreen, and theRed.

2065 {
2066  rCurr = theRed;
2067  gCurr = theGreen;
2068  bCurr = theBlue;
2069 }
ossim_uint8 theGreen
The green component of the color used in drawing the shapes.
ossim_uint8 theRed
The red component of the color used in drawing the shapes.
ossim_uint8 theBlue
The blue component of the color used in drawing the shapes.

◆ getImageData() [1/2]

ossimRefPtr< ossimImageData > ossimRgbImage::getImageData ( )

◆ getImageData() [2/2]

const ossimRefPtr< ossimImageData > ossimRgbImage::getImageData ( ) const

Will take the point passed in and translate to a 0,0.

Example: Let's say that we have origin 45,34 for the image's upper left corner. then a call to this method will translate the point passed in x-45, y-34 Will take the point passed in and translate to a 0,0. Example: Let's say that we have origin 45,34 for the image's upper left corner. then a call to this method will translate the point passed in x-45, y-34

Definition at line 832 of file ossimRgbImage.cpp.

References theImageData.

833 {
834  return theImageData;
835 }
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.

◆ getThickness()

ossim_int32 ossimRgbImage::getThickness ( ) const
Returns
The thickness.

Definition at line 2076 of file ossimRgbImage.cpp.

References theThickness.

2077 {
2078  return theThickness;
2079 }
ossim_int32 theThickness
Holds the draw thickness.

◆ initialize()

void ossimRgbImage::initialize ( )
virtual

Will initilize any pre-computations that are needed.

Example: setting up the origin for adjustments and setting up the offsets.

Definition at line 860 of file ossimRgbImage.cpp.

References ossimImageData::getBuf(), ossimImageData::getHeight(), ossimImageData::getNumberOfBands(), ossimImageData::getWidth(), theBands, theHeight, theImageData, theOffsets, and theWidth.

Referenced by setCurrentImageData().

861 {
862  if(!theImageData)
863  {
864  return;
865  }
866  if(theOffsets)
867  {
868  delete [] theOffsets;
869  theOffsets = 0;
870  }
873 
875  for(ossim_int32 row = 0; row < theHeight; ++row)
876  {
877  theOffsets[row] = row*theWidth;
878  }
879 
880  // make it work for 1, 2, or 3 band data.
881  // we assume the fourth band is for the alpha channel
882  if(theImageData->getNumberOfBands() >= 3)
883  { // point each band to r, g, b.
884  theBands[0] = static_cast<ossim_uint8*>(theImageData->getBuf(0));
885  theBands[1] = static_cast<ossim_uint8*>(theImageData->getBuf(1));
886  theBands[2] = static_cast<ossim_uint8*>(theImageData->getBuf(2));
887  }
888  else if(theImageData->getNumberOfBands() == 2)
889  {//point r and g to the same place
890  theBands[0] = static_cast<ossim_uint8*>(theImageData->getBuf(0));
891  theBands[1] = static_cast<ossim_uint8*>(theImageData->getBuf(0));
892  theBands[2] = static_cast<ossim_uint8*>(theImageData->getBuf(1));
893  }
894  else if(theImageData->getNumberOfBands() == 1)
895  {// point all band s to the first band
896  theBands[0] = static_cast<ossim_uint8*>(theImageData->getBuf(0));
897  theBands[1] = static_cast<ossim_uint8*>(theImageData->getBuf(0));
898  theBands[2] = static_cast<ossim_uint8*>(theImageData->getBuf(0));
899  }
900 }
virtual ossim_uint32 getWidth() const
virtual ossim_uint32 getNumberOfBands() const
virtual ossim_uint32 getHeight() const
ossim_int32 theWidth
This is here so we don&#39;t have to call theWidth and theHeight of the ossimImageData.
ossim_int32 theHeight
This is here so we don&#39;t have to call theWidth and theHeight of the ossimImageData.
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
ossim_uint8 * theBands[3]
This is a fast access to the start of each band.
virtual const void * getBuf() const
ossim_int32 * theOffsets
This will hold precomputed offsets to the start of each row.
unsigned char ossim_uint8
int ossim_int32

◆ setCurrentImageData()

void ossimRgbImage::setCurrentImageData ( ossimRefPtr< ossimImageData > &  imageData)

Allows you to change the image data that this RgbImage object operates on.

You can specify if the image owns the data or not. if it doesn't own the data then it will not destroy it when the data is changed to a different data object or if this object is deleted.

Parameters
imageDataThe tile to annotate or draw to.
Note
This can be any number of bands; however, will only draw to up to 3.

Definition at line 902 of file ossimRgbImage.cpp.

References ossimDataObject::getDataObjectStatus(), ossimRectilinearDataObject::getScalarType(), initialize(), OSSIM_NULL, OSSIM_UCHAR, theImageData, and ossimRefPtr< T >::valid().

Referenced by createNewGrey(), ossimVpfAnnotationSource::drawAnnotations(), ossimGdalOgrVectorAnnotation::drawAnnotations(), ossimEsriShapeFileFilter::drawAnnotations(), ossimAnnotationSource::drawAnnotations(), ossimMapCompositionSource::drawAnnotations(), and ossimRgbImage().

903 {
904  if(imageData.valid())
905  {
906  if((imageData->getScalarType() == OSSIM_UCHAR)&&
907  (imageData->getDataObjectStatus()!=OSSIM_NULL))
908  {
909  theImageData = imageData;
910  initialize();
911  }
912  }
913 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimDataObjectStatus getDataObjectStatus() const
ossimRefPtr< ossimImageData > theImageData
This object operates on the ossimImageData.
virtual ossimScalarType getScalarType() const
virtual void initialize()
Will initilize any pre-computations that are needed.
8 bit unsigned iteger

◆ setDrawColor()

void ossimRgbImage::setDrawColor ( ossim_uint8  r = 255,
ossim_uint8  g = 255,
ossim_uint8  b = 255 
)

Definition at line 2053 of file ossimRgbImage.cpp.

References theBlue, theGreen, and theRed.

Referenced by ossimGeographicAnnotationGrid::draw(), ossimAnnotationEllipseObject::draw(), ossimAnnotationMultiPolyLineObject::draw(), ossimAnnotationPolyObject::draw(), ossimAnnotationMultiEllipseObject::draw(), ossimAnnotationMultiPolyObject::draw(), ossimAnnotationGdBitmapFont::draw(), ossimAnnotationLineObject::draw(), and ossimAnnotationMultiLineObject::draw().

2056 {
2057  theRed = r;
2058  theGreen = g;
2059  theBlue = b;
2060 }
ossim_uint8 theGreen
The green component of the color used in drawing the shapes.
ossim_uint8 theRed
The red component of the color used in drawing the shapes.
ossim_uint8 theBlue
The blue component of the color used in drawing the shapes.

◆ setThickness()

void ossimRgbImage::setThickness ( ossim_int32  thickness)

All the drawing algorithms have thickness.

So you can draw a line that has thickness of 3 pixels if you want. Note: the thickness is in pixels

Definition at line 2071 of file ossimRgbImage.cpp.

References theThickness.

Referenced by ossimAnnotationEllipseObject::draw(), ossimAnnotationMultiPolyLineObject::draw(), ossimAnnotationMultiPolyObject::draw(), ossimAnnotationPolyObject::draw(), ossimAnnotationMultiEllipseObject::draw(), ossimAnnotationLineObject::draw(), and ossimAnnotationMultiLineObject::draw().

2072 {
2073  theThickness = thickness;
2074 }
ossim_int32 theThickness
Holds the draw thickness.

◆ slowPlotPixel()

void ossimRgbImage::slowPlotPixel ( ossim_int32  x,
ossim_int32  y,
ossim_uint8  r,
ossim_uint8  g,
ossim_uint8  b 
)
inline

This will plot a pixel and will do inside outside compares.

This assumes the pixel has already been put into a relative 0,0 to the upper left corner of the image data.

example: if the upperleft corner or origin of the image was 34, 55 then it assumes that the points passed in are already relative to that corner not absolute.

Definition at line 380 of file ossimRgbImage.h.

References theBands, theHeight, theOffsets, theWidth, x, and y.

Referenced by ossimAnnotationGdBitmapFont::draw(), drawFilledRectangle(), and drawLine().

385 {
386  if((x > -1) && (x < theWidth) &&
387  (y > -1) && (y < theHeight))
388  {
389  theBands[0][theOffsets[y]+x] = r;
390  theBands[1][theOffsets[y]+x] = g;
391  theBands[2][theOffsets[y]+x] = b;
392  }
393 }
ossim_uint32 x
ossim_uint32 y
ossim_int32 theWidth
This is here so we don&#39;t have to call theWidth and theHeight of the ossimImageData.
ossim_int32 theHeight
This is here so we don&#39;t have to call theWidth and theHeight of the ossimImageData.
ossim_uint8 * theBands[3]
This is a fast access to the start of each band.
ossim_int32 * theOffsets
This will hold precomputed offsets to the start of each row.

Member Data Documentation

◆ theBands

ossim_uint8* ossimRgbImage::theBands[3]
protected

This is a fast access to the start of each band.

Definition at line 344 of file ossimRgbImage.h.

Referenced by fastPlotPixel(), initialize(), and slowPlotPixel().

◆ theBlue

ossim_uint8 ossimRgbImage::theBlue
protected

The blue component of the color used in drawing the shapes.

Definition at line 377 of file ossimRgbImage.h.

Referenced by drawFilledRectangle(), drawLine(), fill(), getDrawColor(), and setDrawColor().

◆ theGreen

ossim_uint8 ossimRgbImage::theGreen
protected

The green component of the color used in drawing the shapes.

Definition at line 372 of file ossimRgbImage.h.

Referenced by drawFilledRectangle(), drawLine(), fill(), getDrawColor(), and setDrawColor().

◆ theHeight

ossim_int32 ossimRgbImage::theHeight
protected

This is here so we don't have to call theWidth and theHeight of the ossimImageData.

Definition at line 356 of file ossimRgbImage.h.

Referenced by fill(), initialize(), and slowPlotPixel().

◆ theImageData

ossimRefPtr<ossimImageData> ossimRgbImage::theImageData
protected

This object operates on the ossimImageData.

Note the ossimImageData is a band separate so the bands follow sequentially: all the reds followed by all the blues followed by all greens

Definition at line 331 of file ossimRgbImage.h.

Referenced by createNewGrey(), createNewTrueColor(), drawArc(), drawEllipse(), drawFilledArc(), drawFilledEllipse(), drawFilledPolygon(), drawLine(), drawPolygon(), fill(), getImageData(), initialize(), and setCurrentImageData().

◆ theOffsets

ossim_int32* ossimRgbImage::theOffsets
protected

This will hold precomputed offsets to the start of each row.

This will get rid of a multiplication per access. Since we will be accessing on a per pixel basis this will be needed.

Definition at line 339 of file ossimRgbImage.h.

Referenced by fastPlotPixel(), initialize(), slowPlotPixel(), and ~ossimRgbImage().

◆ theRed

ossim_uint8 ossimRgbImage::theRed
protected

The red component of the color used in drawing the shapes.

Definition at line 367 of file ossimRgbImage.h.

Referenced by drawFilledRectangle(), drawLine(), fill(), getDrawColor(), and setDrawColor().

◆ theThickness

ossim_int32 ossimRgbImage::theThickness
protected

Holds the draw thickness.

Definition at line 361 of file ossimRgbImage.h.

Referenced by drawLine(), drawRectangle(), getThickness(), and setThickness().

◆ theWidth

ossim_int32 ossimRgbImage::theWidth
protected

This is here so we don't have to call theWidth and theHeight of the ossimImageData.

Definition at line 350 of file ossimRgbImage.h.

Referenced by fill(), initialize(), and slowPlotPixel().


The documentation for this class was generated from the following files: