Пример #1
0
bool SaveTarga32( const CImage32* pImage, const char* pNameFile )
{
	if (!pNameFile)
	{
		return false;
	}

	UINT width = pImage->Width();
	UINT height = pImage->Height();

	uint8_t* pBuffer = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(pImage->PixelAddress( 0, 0 )));
	tga_result result = tga_write_bgr_rle( pNameFile, pBuffer, width, height, 32 );

	return (result == TGA_NOERR) ? true : false;
}
Пример #2
0
static int write_image_tga(void * priv, gavl_video_frame_t * frame)
  {
  tga_t * tga = priv;
  gavl_video_frame_t * tmp_frame;
  int result, ret = 1;

  errno = 0;

  if(tga->format.pixelformat == GAVL_RGBA_32)
    {
    tmp_frame = gavl_video_frame_create(&tga->format);
    gavl_video_frame_copy(&tga->format, tmp_frame, frame);
    if(tga->rle)
      {
      result = tga_write_rgb(tga->filename, tmp_frame->planes[0],
                             tga->format.image_width,
                             tga->format.image_height, 32,
                             frame->strides[0]);
      }
    else
      {
      result =tga_write_rgb_rle(tga->filename, tmp_frame->planes[0],
                                tga->format.image_width,
                                tga->format.image_height, 32,
                                frame->strides[0]);
      }
    gavl_video_frame_destroy(tmp_frame);
    }
  else
    {
    if(tga->rle)
      {
      result = tga_write_bgr(tga->filename, frame->planes[0],
                             tga->format.image_width,
                             tga->format.image_height, 24,
                             frame->strides[0]);
      }
    else
      {
      result = tga_write_bgr_rle(tga->filename, frame->planes[0],
                                 tga->format.image_width,
                                 tga->format.image_height, 24,
                                 frame->strides[0]);
      }
    }

  if(result != TGA_NOERR)
    {
    if(errno)
      bg_log(BG_LOG_ERROR, LOG_DOMAIN, "Cannot save %s: %s",
             tga->filename, strerror(errno));
    else
      bg_log(BG_LOG_ERROR, LOG_DOMAIN, "Cannot save %s: %s",
             tga->filename, tga_error(result));
    ret = 0;
    }

  free(tga->filename);
  tga->filename = NULL;
  
  return ret;
  }