예제 #1
0
파일: puyo.cpp 프로젝트: jonghyunho/puyo
BufferImage CreateBitmapImage(float width, float height)
{
  BufferImage image = BufferImage::New(width, height, Pixel::RGBA8888);

  PixelBuffer* pixbuf = image.GetBuffer();

  // Using a 4x4 image gives a better blend with the GL implementation
  // than a 3x3 image
  for(size_t i=0; i<16; i++)
  {
    pixbuf[i*4+0] = 0xFF;
    pixbuf[i*4+1] = 0xFF;
    pixbuf[i*4+2] = 0xFF;
    pixbuf[i*4+3] = 0xFF;
  }

  return image;
}
예제 #2
0
BufferImage CreateBufferImage(int width, int height, const Vector4& color)
{
  BufferImage image = BufferImage::New(width, height, Pixel::RGBA8888);

  PixelBuffer* pixbuf = image.GetBuffer();

  // Using a 4x4 image gives a better blend with the GL implementation
  // than a 3x3 image
  for(size_t i=0; i<16; i++)
  {
    pixbuf[i*4+0] = color.r*255;
    pixbuf[i*4+1] = color.g*255;
    pixbuf[i*4+2] = color.b*255;
    pixbuf[i*4+3] = color.a*255;
  }

  return image;
}
예제 #3
0
  BufferImage CreateBufferImage( const Vector4& color, const unsigned int width, const unsigned int height )
  {
    BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 );

    // Create the image
    PixelBuffer* pixbuf = imageData.GetBuffer();
    const unsigned int bitmapSize = width * height;
    for( size_t i = 0; i < bitmapSize; ++i )
    {
      pixbuf[i*4+0] = 0xFF * color.r;
      pixbuf[i*4+1] = 0xFF * color.g;
      pixbuf[i*4+2] = 0xFF * color.b;
      pixbuf[i*4+3] = 0xFF * color.a;
    }

    imageData.Update();

    return imageData;
  }
void CreatePropertyMap( Image image, Property::Map& map )
{
  map.Clear();

  if ( image )
  {
    std::string imageType( "ResourceImage" );

    // Get Type - cannot use TypeRegistry as Image is not an Object and thus, not registered
    BufferImage bufferImage = BufferImage::DownCast( image );
    if ( bufferImage )
    {
      imageType = "BufferImage";
      map[ "pixelFormat" ] = GetEnumerationName< Pixel::Format >( bufferImage.GetPixelFormat(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT );
    }
    else if ( FrameBufferImage::DownCast( image ) )
    {
      imageType = "FrameBufferImage";
    }

    map[ "type" ] = imageType;
    map[ "releasePolicy" ] = GetEnumerationName< Image::ReleasePolicy >( image.GetReleasePolicy(), IMAGE_RELEASE_POLICY_TABLE, IMAGE_RELEASE_POLICY_TABLE_COUNT );

    ResourceImage resourceImage = ResourceImage::DownCast( image );
    if( resourceImage )
    {
      map[ "filename" ] = resourceImage.GetUrl();
      map[ "loadPolicy" ] = GetEnumerationName< ResourceImage::LoadPolicy >( resourceImage.GetLoadPolicy(), IMAGE_LOAD_POLICY_TABLE, IMAGE_LOAD_POLICY_TABLE_COUNT );
    }

    int width( image.GetWidth() );
    int height( image.GetHeight() );

    if ( width && height )
    {
      map[ "width" ] = width;
      map[ "height" ] = height;
    }
  }
}
예제 #5
0
ImageActor CreateSolidColorActor( const Vector4& color, bool border, const Vector4& borderColor, const unsigned int borderSize )
{
  ImageActor image;
  if( borderSize > MAX_BORDER_SIZE )
  {
    return image;
  }

  const unsigned int bitmapWidth = borderSize * 2 + 2;
  bool needAlphaChannel = (color.a < 1.0f) || ( border && borderColor.a < 1.0f );
  BufferImage imageData;
  if( needAlphaChannel )
  {
    imageData = BufferImage::New( bitmapWidth, bitmapWidth, Pixel::RGBA8888 );
  }
  else
  {
    imageData = BufferImage::New( bitmapWidth, bitmapWidth, Pixel::RGB888 );
  }

  // Create the image
  PixelBuffer* pixbuf = imageData.GetBuffer();
  if( !pixbuf )
  {
    return image;
  }

  Vector4 outerColor = color;
  if ( border )
  {
    outerColor = borderColor;
  }

  // Using a (2 + border) x (2 + border) image gives a better blend with the GL implementation
  // than a (1 + border) x (1 + border) image
  const unsigned int bitmapSize = bitmapWidth * bitmapWidth;
  const unsigned int topLeft = bitmapWidth * borderSize + borderSize;
  const unsigned int topRight = topLeft + 1;
  const unsigned int bottomLeft = bitmapWidth * (borderSize + 1) + borderSize;
  const unsigned int bottomRight = bottomLeft + 1;

  if( needAlphaChannel )
  {
    for( size_t i = 0; i < bitmapSize; ++i )
    {
      if( i == topLeft ||
          i == topRight ||
          i == bottomLeft ||
          i == bottomRight )
      {
        pixbuf[i*4+0] = 0xFF * color.r;
        pixbuf[i*4+1] = 0xFF * color.g;
        pixbuf[i*4+2] = 0xFF * color.b;
        pixbuf[i*4+3] = 0xFF * color.a;
      }
      else
      {
        pixbuf[i*4+0] = 0xFF * outerColor.r;
        pixbuf[i*4+1] = 0xFF * outerColor.g;
        pixbuf[i*4+2] = 0xFF * outerColor.b;
        pixbuf[i*4+3] = 0xFF * outerColor.a;
      }
    }
  }
  else
  {
    for( size_t i = 0; i < bitmapSize; ++i )
    {
      if( i == topLeft ||
          i == topRight ||
          i == bottomLeft ||
          i == bottomRight )
      {
        pixbuf[i*3+0] = 0xFF * color.r;
        pixbuf[i*3+1] = 0xFF * color.g;
        pixbuf[i*3+2] = 0xFF * color.b;
      }
      else
      {
        pixbuf[i*3+0] = 0xFF * outerColor.r;
        pixbuf[i*3+1] = 0xFF * outerColor.g;
        pixbuf[i*3+2] = 0xFF * outerColor.b;
      }
    }
  }

  imageData.Update();
  image = ImageActor::New( imageData );
  image.SetParentOrigin( ParentOrigin::CENTER );

  if( border )
  {
    image.SetStyle( ImageActor::STYLE_NINE_PATCH );
    image.SetNinePatchBorder( Vector4::ONE * (float)borderSize * 2.0f );
  }

  return image;
}