本文整理汇总了C++中Image2D::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Image2D::GetWidth方法的具体用法?C++ Image2D::GetWidth怎么用?C++ Image2D::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image2D
的用法示例。
在下文中一共展示了Image2D::GetWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Image2D::Image2D(Image2D const& _cpy)
{
SetText(_cpy.GetText());
m_fg = _cpy.GetForegroundColor();
m_bg = _cpy.GetBackgroundColor();
m_width = _cpy.GetWidth();
m_height = _cpy.GetHeight();
}
示例2: fclose
bool Image2DPngExporter::Export( const std::string& filename, const Image2D& image )
{
FILE* file;
png_structp write;
png_infop info;
png_bytepp rowBuf;
uint width = image.GetWidth();
uint height = image.GetHeight();
unsigned char* buffer = (unsigned char*)&image.GetPixels()[0];
if( ( file = fopen( filename.c_str(), "wb" ) ) == 0 )
{
return false;
}
// Creates structure.
write = png_create_write_struct(
PNG_LIBPNG_VER_STRING, (png_voidp)0,
(png_error_ptr)0, (png_error_ptr)0
);
info = png_create_info_struct( write );
// Verify for errors.
if( setjmp( png_jmpbuf( write ) ) )
{
png_destroy_write_struct( &write, &info );
fclose( file );
return false;
}
// Write header.
png_init_io( write, file );
png_set_IHDR(
write,
info,
width,
height,
8,
_pngChannels[2],
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE,
PNG_FILTER_TYPE_BASE
);
png_write_info( write, info );
// Write image
rowBuf = new png_bytep[height];
PixelType _type = yTE;
int _pixelSize = pixelTypeSize[_type] * 3;
int _lineSize = _pixelSize * width; // no padding for now
for( int i = 0; i < (int)height; ++i )
{
rowBuf[height-i-1] = &buffer[_lineSize*i];
}
png_write_image( write, rowBuf );
// Clean up after the write, and free any memory allocated - REQUIRED
png_write_end( write, info );
png_destroy_write_struct( &write, &info );
delete[] rowBuf;
fclose( file );
return true;
}