OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimRgbToJpegYCbCrSource.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: ossimRgbToJpegYCbCrSource.cpp 9094 2006-06-13 19:12:40Z dburken $
15 #include <ossim/base/ossimCommon.h>
18 
20  "ossimRgbToJpegYCbCrSource",
22 
25 {
26  theBlankTile = new ossimImageData(this,
28  3);
29 }
30 
32  : ossimImageSourceFilter(inputSource)
33 {
34 }
35 
37 {
38 }
39 
41  ossim_uint32 resLevel)
42 {
43  theBlankTile->setOrigin(tileRect.ul());
44  theBlankTile->setWidthHeight(tileRect.width(), tileRect.height());
45 
47  {
49  resLevel);
50  if(!imageData.valid())
51  {
52  return theBlankTile;
53  }
54  if((isSourceEnabled())&&
55  (imageData->getNumberOfBands()==3)&&
56  (imageData->getScalarType()==OSSIM_UCHAR)&&
57  (imageData->getDataObjectStatus()!=OSSIM_NULL)&&
58  (imageData->getDataObjectStatus()!=OSSIM_EMPTY))
59  {
60  ossim_uint8* bands[3];
61 
62  bands[0] = static_cast<ossim_uint8*>(imageData->getBuf(0));
63  bands[1] = static_cast<ossim_uint8*>(imageData->getBuf(1));
64  bands[2] = static_cast<ossim_uint8*>(imageData->getBuf(2));
65 
66  long height = imageData->getHeight();
67  long width = imageData->getWidth();
68  long offset = 0;
69 
70  for(long row = 0; row < height; ++row)
71  {
72  for(long col = 0; col < width; ++col)
73  {
74  ossimRgbVector rgb(bands[0][offset],
75  bands[1][offset],
76  bands[2][offset]);
77 
78  ossimJpegYCbCrVector ycbcr(rgb);
79 
80 
81  bands[0][offset] = ycbcr.getY();
82  bands[1][offset] = ycbcr.getCb();
83  bands[2][offset] = ycbcr.getCr();
84  ++offset;
85  }
86  }
87  imageData->validate();
88  }
89  return imageData;
90  }
91 
92  return theBlankTile;
93 }
virtual ossim_uint32 getWidth() const
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual ossim_uint32 getNumberOfBands() const
virtual void setWidthHeight(ossim_uint32 w, ossim_uint32 h)
bool valid() const
Definition: ossimRefPtr.h:75
ossim_uint32 height() const
Definition: ossimIrect.h:487
ossimRefPtr< ossimImageData > theBlankTile
const ossimIpt & ul() const
Definition: ossimIrect.h:274
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
unsigned char getY() const
virtual ossimDataObjectStatus validate() const
ossimImageSource * theInputConnection
unsigned int ossim_uint32
ossim_uint32 width() const
Definition: ossimIrect.h:500
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tileRect, ossim_uint32 resLevel=0)
virtual void setOrigin(const ossimIpt &origin)
virtual ossimScalarType getScalarType() const
virtual const void * getBuf() const
unsigned char getCr() const
RTTI_DEF1(ossimRgbToJpegYCbCrSource, "ossimRgbToJpegYCbCrSource", ossimImageSourceFilter) ossimRgbToJpegYCbCrSource
unsigned char getCb() const
unsigned char ossim_uint8
8 bit unsigned iteger
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)