コード例 #1
0
int
BitmapToYXBandedRectangles(ImageRect * pSrcRect, RECT_T * out)
{
    RECT_T *pPrevLine = NULL, *pFirst = out, *pThis = pFirst;
    int i, j, i0;
    int length;

    for (j = 0; j < pSrcRect->numLines; j++) {

        /* generate data for a scanline */

        byte_t *pSrc = (byte_t *) pSrcRect->pBits + j * pSrcRect->stride;
        RECT_T *pLine = pThis;

        i = 0;

        do {
            while (i < pSrcRect->numSamples &&
                   getRGBA(pSrc, pSrcRect->format) < ALPHA_THRESHOLD) {
                pSrc += pSrcRect->depthBytes;
                ++i;
            }
            if (i >= pSrcRect->numSamples) {
                break;
            }
            i0 = i;
            while (i < pSrcRect->numSamples &&
                   getRGBA(pSrc, pSrcRect->format) >= ALPHA_THRESHOLD) {
                pSrc += pSrcRect->depthBytes;
                ++i;
            }
            RECT_SET(*pThis, i0, j, i - i0, 1);
            ++pThis;
        } while (i < pSrcRect->numSamples);

        /*  check if the previous scanline is exactly the same, merge if so
           (this is the only optimization we can use for YXBanded rectangles, and win32 supports
           YXBanded only */

        length = pThis - pLine;
        if (pPrevLine && pLine - pPrevLine == length) {
            for (i = 0; i < length && RECT_EQ_X(pPrevLine[i], pLine[i]); ++i) {
            }
            if (i == pLine - pPrevLine) {
                // do merge
                for (i = 0; i < length; i++) {
                    RECT_INC_HEIGHT(pPrevLine[i]);
                }
                pThis = pLine;
                continue;
            }
        }
        /* or else use the generated scanline */

        pPrevLine = pLine;
    }
    return pThis - pFirst;
}
コード例 #2
0
ファイル: oofimage3d.C プロジェクト: anilkunwar/OOF2
OOFImage3D::OOFImage3D(const std::string &name, const ICoord &isize,
		       const std::vector<unsigned short> *data) 
  : name_(name)
{
  image = vtkImageData::New();
  image->SetDimensions(isize(0),isize(1),isize(2));
  image->SetScalarTypeToUnsignedChar();
  image->SetNumberOfScalarComponents(3);
  image->AllocateScalars();

  int i,j,k;
  for (i=0; i<isize(0); i++) {
    for (j=0; j<isize(1); j++) {
      for (k=0; k<isize(2); k++) {			
	image->SetScalarComponentFromFloat(i,j,k,0,
					   (float)((*data)[3*(i*(isize(1))*(isize(2))+j*isize(2)+k)]));
	image->SetScalarComponentFromFloat(i,j,k,1,
					   (float)((*data)[3*(i*(isize(1))*(isize(2))+j*isize(2)+k)+1]));
	image->SetScalarComponentFromFloat(i,j,k,2,
					   (float)((*data)[3*(i*(isize(1))*(isize(2))+j*isize(2)+k)+2]));
      }
    }
  }	

  image->Update();
  image = getRGBA();
  padImage(1);

  setup();
}
コード例 #3
0
ファイル: Color.cpp プロジェクト: oroisec/ios
bool Color::isDark() const
{
    float r, g, b, a, h, s, v;
    getRGBA(r, g, b, a);
    convertRGBToHSV(r, g, b, h, s, v);
    
    return a > 0.5 && v < 0.5;
}
コード例 #4
0
ファイル: tga.c プロジェクト: bgianfo/computer-graphics
/*
=============
getData

Gets the image data for the specified bit depth.
=============
*/
char *getData (FILE *s, int sz, int iBits)
{
    if (iBits == 32)
        return getRGBA (s, sz);
    else if (iBits == 24)
        return getRGB (s, sz);	
    else if (iBits == 8)
        return getGray (s, sz);
}
コード例 #5
0
ファイル: Color.cpp プロジェクト: oroisec/ios
Color Color::dark() const
{
    float r, g, b, a, h, s, v;
    getRGBA(r, g, b, a);
    convertRGBToHSV(r, g, b, h, s, v);
    v = max(0.0f, min(v - 0.33f, 1.0f));
    convertHSVToRGB(h, s, v, r, g, b);
    return Color((int)(r * 255), (int)(g * 255), (int)(b * 255), (int)(a * 255));
}
コード例 #6
0
ファイル: Color.cpp プロジェクト: Happy-Ferret/webkit.js
bool Color::isDark() const
{
    float red;
    float green;
    float blue;
    float alpha;
    getRGBA(red, green, blue, alpha);
    float largestNonAlphaChannel = std::max(red, std::max(green, blue));
    return alpha > 0.5 && largestNonAlphaChannel < 0.5;
}
コード例 #7
0
ファイル: tga.cpp プロジェクト: brizzly/Halloween3D
char *getData (FILE *s, int sz, int imageWidth, int imageHeight, int iBits, int picmip)
{
	char *data;

	if (iBits == 32)
		return (char *)getRGBA (s, sz, picmip);
	else if (iBits == 24)
	{
		data = (char *)getRGB (s, sz, imageWidth, imageHeight, picmip);
		return data;
	}

	return NULL;
}
コード例 #8
0
ファイル: Color.cpp プロジェクト: 335969568/Blink-1
Color Color::dark() const
{
    // Hardcode this common case for speed.
    if (m_color == white)
        return darkenedWhite;

    const float scaleFactor = nextafterf(256.0f, 0.0f);

    float r, g, b, a;
    getRGBA(r, g, b, a);

    float v = std::max(r, std::max(g, b));
    float multiplier = std::max(0.0f, (v - 0.33f) / v);

    return Color(static_cast<int>(multiplier * r * scaleFactor),
                 static_cast<int>(multiplier * g * scaleFactor),
                 static_cast<int>(multiplier * b * scaleFactor),
                 alpha());
}
コード例 #9
0
ファイル: tga.cpp プロジェクト: leofiao/SI_P2
void TGAImage::initFirstLOD( unsigned char* srcData)
{

	lodData[0] = new unsigned char[ getLODwidth(0) * getLODheight(0) * BPP ] ;
	
	for( int i = 0 ; i < getLODwidth(0) ; i++ )
		for( int j = 0 ; j < getLODheight(0) ; j++ )
		{
			unsigned char r, g, b, a ;
			if( srcData ) getRGBA( srcData, i, getLODheight(0) - 1 - j, r, g, b, a ) ;
			else r = g = b = a = 0 ;

			setR( 0, i, j, r ) ;
			setG( 0, i, j, g ) ;
			setB( 0, i, j, b ) ;
			setA( 0, i, j, a ) ;
		}
	goodLOD = 0 ;
}
コード例 #10
0
ファイル: Color.cpp プロジェクト: 335969568/Blink-1
Color Color::light() const
{
    // Hardcode this common case for speed.
    if (m_color == black)
        return lightenedBlack;

    const float scaleFactor = nextafterf(256.0f, 0.0f);

    float r, g, b, a;
    getRGBA(r, g, b, a);

    float v = std::max(r, std::max(g, b));

    if (v == 0.0f)
        // Lightened black with alpha.
        return Color(0x54, 0x54, 0x54, alpha());

    float multiplier = std::min(1.0f, v + 0.33f) / v;

    return Color(static_cast<int>(multiplier * r * scaleFactor),
                 static_cast<int>(multiplier * g * scaleFactor),
                 static_cast<int>(multiplier * b * scaleFactor),
                 alpha());
}
コード例 #11
0
ファイル: UiLibrary.cpp プロジェクト: ghuysmans/metacombi
void Surface::rect(SDL_Rect *dest, const SDL_Color& c) {
	SDL_FillRect(surface, dest, getRGBA(c));
}
コード例 #12
0
ファイル: UiLibrary.cpp プロジェクト: ghuysmans/metacombi
void Surface::circle(Sint16 x, Sint16 y, Sint16 r, const SDL_Color& c) {
	aacircleColor(surface, x, y, r, getRGBA(c));
}
コード例 #13
0
ファイル: UiLibrary.cpp プロジェクト: ghuysmans/metacombi
void Surface::trigon(Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, const SDL_Color& c) {
	aatrigonColor(surface, x1, y1, x2, y2, x3, y3, getRGBA(c));
}
コード例 #14
0
ファイル: UiLibrary.cpp プロジェクト: ghuysmans/metacombi
void Surface::line(Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, const SDL_Color& c) {
	aalineColor(surface, x1, y1, x2, y2, getRGBA(c));
}
コード例 #15
0
ファイル: UiLibrary.cpp プロジェクト: ghuysmans/metacombi
void Surface::thickLine(Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, const SDL_Color& c) {
	thickLineColor(surface, x1, y1, x2, y2, width, getRGBA(c));
}
コード例 #16
0
ファイル: oofimage3d.C プロジェクト: anilkunwar/OOF2
OOFImage3D::OOFImage3D(const std::string &name, const std::string &format, const std::string &filepattern, int numfiles)
  : name_(name)
{

  vtkImageReader2 *imageReader;
  vtkIndent indent;
  int depth = numfiles;
  // the width and height seem to be set automatically
  int extent[6] = {0,0,0,0,0,depth-1};

  if(format.compare("pnm")==0 || format.compare("pbm")==0 || format.compare("ppm")==0) {
    imageReader = vtkPNMReader::New();
  }
  else if(format.compare("jpeg")==0) {
    imageReader = vtkJPEGReader::New();
  }
  else if(format.compare("tiff")==0) {
    imageReader = vtkTIFFReader::New();
  }  
  else if(format.compare("png")==0) {
    imageReader = vtkPNGReader::New();
  }
  else
    throw ErrSetupError("Incompatible image format: " + format);

  //cout << "imageReader refcount " << imageReader->GetReferenceCount() << endl;
  //imageReader->SetReferenceCount(1);
  //imageReader->UnRegister((vtkObjectBase*)imageReader->GetExecutive());
  //cout << "imageReader refcount " << imageReader->GetReferenceCount() << endl;
	
  imageReader->SetDataExtent(extent);
  imageReader->SetDataSpacing(1,1,1);
  imageReader->SetFilePattern( filepattern.c_str() );
  imageReader->SetDataScalarTypeToUnsignedChar();
  //cout << imageReader->GetReleaseDataFlag() << endl;
  //imageReader->ReleaseDataFlagOn();
  //imageReader->DebugOn();
  //cout << imageReader->GetReleaseDataFlag() << endl;
  //cout << "imageReader refcount " << imageReader->GetReferenceCount() << endl;


  image = imageReader->GetOutput();
  image->Update();
  pipeline.push_back(imageReader);
 
  // for certain image formats such as PNG, the bit depth may be
  // greater than 8 and the reader will return a vtkImageData object
  // with a scalar type other than unsigned char.  We need to scale
  // the data and make it an unsigned char type
  if(image->GetScalarType() != VTK_UNSIGNED_CHAR) {
    vtkImageShiftScale *shiftscale = vtkImageShiftScale::New();
    shiftscale->SetInput(image);
    shiftscale->SetShift(0);
    shiftscale->SetScale(255.0/image->GetScalarTypeMax());
    shiftscale->SetOutputScalarTypeToUnsignedChar();
    image = shiftscale->GetOutput();
    image->Update();
    pipeline.push_back(shiftscale);
  }


  //image->DebugOn();
  //cout << "image refcount " << image->GetReferenceCount() << endl;
  //image->Register(NULL);
  //cout << "image refcount " << image->GetReferenceCount() << endl;
  //image->SetSource(NULL);
  //cout << "image refcount " << image->GetReferenceCount() << endl;
  //imageReader->Delete();
  //cout << "image refcount " << image->GetReferenceCount() << endl;

  image = getRGBA();
  padImage(1);
  //image->PrintSelf(cout, indent);

  setup();

}