OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimJpegYCbCrToRgbSource.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: ossimJpegYCbCrToRgbSource.cpp 9094 2006-06-13 19:12:40Z dburken $
15 #include <ossim/base/ossimCommon.h>
18 
20  "ossimJpegYCbCrToRgbSource" ,
22 
25  theBlankTile()
26 {
27 }
28 
30  : ossimImageSourceFilter(inputSource),
31  theBlankTile()
32 {
33 }
34 
36 {
37 }
38 
40 {
42 }
43 
45 {
46  theBlankTile = new ossimImageData(this,
48  3);
49 }
50 
52  const ossimIrect& tileRect,
53  ossim_uint32 resLevel)
54 {
55  if (!theBlankTile.valid())
56  {
57  allocate(); // first time through.
58  }
59 
60  if(theBlankTile.valid())
61  {
62  theBlankTile->setOrigin(tileRect.ul());
63  theBlankTile->setWidthHeight(tileRect.width(), tileRect.height());
64  }
65 
67  {
68  ossimRefPtr<ossimImageData> imageData =
69  theInputConnection->getTile(tileRect, resLevel);
70 
71  if(!imageData.valid())
72  {
73  return theBlankTile;
74  }
75  if((isSourceEnabled())&&
76  (imageData->getNumberOfBands()==3)&&
77  (imageData->getScalarType()==OSSIM_UCHAR)&&
78  (imageData->getDataObjectStatus()!=OSSIM_NULL)&&
79  (imageData->getDataObjectStatus()!=OSSIM_EMPTY))
80  {
81  ossim_uint8* bands[3];
82 
83  bands[0] = static_cast<ossim_uint8*>(imageData->getBuf(0));
84  bands[1] = static_cast<ossim_uint8*>(imageData->getBuf(1));
85  bands[2] = static_cast<ossim_uint8*>(imageData->getBuf(2));
86 
87  long height = imageData->getHeight();
88  long width = imageData->getWidth();
89  long offset = 0;
90  for(long row = 0; row < height; ++row)
91  {
92  for(long col = 0; col < width; ++col)
93  {
94 
95  ossimJpegYCbCrVector ycbcr(bands[0][offset],
96  bands[1][offset],
97  bands[2][offset]);
98  ossimRgbVector rgb(ycbcr);
99 
100 
101  bands[0][offset] = rgb.getR();
102  bands[1][offset] = rgb.getG();
103  bands[2][offset] = rgb.getB();
104 
105  ++offset;
106  }
107  }
108  imageData->validate();
109  }
110  return imageData;
111  }
112 
113  return theBlankTile;
114 }
virtual ossim_uint32 getWidth() const
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual ossim_uint32 getNumberOfBands() const
unsigned char getR() const
RTTI_DEF1(ossimJpegYCbCrToRgbSource, "ossimJpegYCbCrToRgbSource", ossimImageSourceFilter) ossimJpegYCbCrToRgbSource
virtual void setWidthHeight(ossim_uint32 w, ossim_uint32 h)
bool valid() const
Definition: ossimRefPtr.h:75
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
virtual ossimDataObjectStatus validate() const
ossimImageSource * theInputConnection
unsigned int ossim_uint32
unsigned char getB() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimRefPtr< ossimImageData > theBlankTile
virtual void setOrigin(const ossimIpt &origin)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &origin, ossim_uint32 resLevel=0)
unsigned char getG() const
virtual ossimScalarType getScalarType() const
virtual const void * getBuf() const
unsigned char ossim_uint8
8 bit unsigned iteger
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)