本文整理汇总了C++中png_read_row函数的典型用法代码示例。如果您正苦于以下问题:C++ png_read_row函数的具体用法?C++ png_read_row怎么用?C++ png_read_row使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了png_read_row函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: read_image
int read_image (dt_imageio_png_t *png, void *out)
{
if (setjmp(png_jmpbuf(png->png_ptr)))
{
fclose(png->f);
png_destroy_read_struct(&png->png_ptr, NULL, NULL);
return 1;
}
// reflect changes
png_read_update_info(png->png_ptr, png->info_ptr);
png_bytep row_pointer = (png_bytep) out;
unsigned long rowbytes = png_get_rowbytes(png->png_ptr, png->info_ptr);
for (int y = 0; y < png->height; y++)
{
png_read_row(png->png_ptr, row_pointer, NULL);
row_pointer += rowbytes;
}
png_read_end(png->png_ptr, png->info_ptr);
png_destroy_read_struct(&png->png_ptr, &png->info_ptr, NULL);
fclose(png->f);
return 0;
}
开发者ID:EvilBit,项目名称:darktable,代码行数:26,代码来源:imageio_png.c
示例2: read_scanline
void read_scanline( byte_t* dst )
{
png_read_row( this->get()->_struct
, dst
, NULL
);
}
开发者ID:BackupTheBerlios,项目名称:airdc-svn,代码行数:7,代码来源:scanline_read.hpp
示例3: res_create_theme_display_surface
int res_create_theme_display_surface(const char* name, const char* themename, gr_surface* pSurface) {
gr_surface surface = NULL;
int result = 0;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
png_uint_32 width, height;
png_byte channels;
*pSurface = NULL;
result = open_theme_png(name, themename, &png_ptr, &info_ptr, &width, &height, &channels);
if (result < 0) return result;
surface = init_display_surface(width, height);
if (surface == NULL) {
result = -8;
goto exit;
}
unsigned char* p_row = malloc(width * 4);
unsigned int y;
for (y = 0; y < height; ++y) {
png_read_row(png_ptr, p_row, NULL);
transform_rgb_to_draw(p_row, surface->data + y * surface->row_bytes, channels, width);
}
free(p_row);
*pSurface = surface;
exit:
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
if (result < 0 && surface != NULL) free(surface);
return result;
}
开发者ID:TheNameIsNigel,项目名称:poc_bootable_recovery,代码行数:34,代码来源:resources.c
示例4: each_interlace_none
static VALUE each_interlace_none(struct each_args *args)
{
struct readerdata *reader;
unsigned char *inwidthbuf, *outwidthbuf, *yinbuf;
struct xscaler *xs;
struct yscaler *ys;
uint32_t i, scaley;
int cmp;
reader = args->reader;
xs = &args->xs;
inwidthbuf = xscaler_psl_pos0(xs);
outwidthbuf = args->outwidthbuf;
ys = &args->ys;
scaley = reader->scale_height;
cmp = png_get_channels(reader->png, reader->info);
png_write_info(args->wpng, args->winfo);
for(i=0; i<scaley; i++) {
while ((yinbuf = yscaler_next(ys))) {
png_read_row(reader->png, inwidthbuf, NULL);
xscaler_scale(xs, yinbuf);
}
yscaler_scale(ys, outwidthbuf, i, cmp, 0);
png_write_row(args->wpng, outwidthbuf);
}
png_write_end(args->wpng, args->winfo);
return Qnil;
}
开发者ID:ender672,项目名称:oil,代码行数:31,代码来源:png.c
示例5: Read3ByteRow
static void
Read3ByteRow(png_structp png_ptr, unsigned char *tmpRow, unsigned char *ImgData, int row_num, int width)
{
int pos;
unsigned char *img_ptr, *tmp_ptr;
png_read_row(png_ptr, tmpRow, NULL);
img_ptr = ImgData + (row_num * width * 4);
tmp_ptr = tmpRow;
for (pos = 0; pos < width; pos++)
{
*img_ptr = *tmp_ptr;
img_ptr++;
tmp_ptr++;
*img_ptr = *tmp_ptr;
img_ptr++;
tmp_ptr++;
*img_ptr = *tmp_ptr;
img_ptr++;
tmp_ptr++;
*img_ptr = 255; /* Alpha channel */
img_ptr++;
}
}
开发者ID:mcr,项目名称:vtwm,代码行数:25,代码来源:image_formats.c
示例6: p_gets
static VALUE
p_gets(VALUE self)
{
struct png_data *reader;
png_structp png_ptr;
png_infop info_ptr;
png_uint_32 sl_width;
size_t height;
VALUE sl;
Data_Get_Struct(self, struct png_data, reader);
png_ptr = reader->png_ptr;
info_ptr = reader->info_ptr;
height = png_get_image_height(png_ptr, info_ptr);
if (reader->lineno >= height)
return Qnil;
sl_width = png_get_rowbytes(png_ptr, info_ptr);
sl = rb_str_new(0, sl_width);
png_read_row(png_ptr, (png_bytep)RSTRING_PTR(sl), (png_bytep)NULL);
reader->lineno += 1;
if (reader->lineno >= height)
png_read_end(png_ptr, info_ptr);
return sl;
}
开发者ID:ender672,项目名称:axon,代码行数:29,代码来源:png.c
示例7: png_read_image
/* Read the entire image. If the image has an alpha channel or a tRNS
* chunk, and you have called png_handle_alpha()[*], you will need to
* initialize the image to the current image that PNG will be overlaying.
* We set the num_rows again here, in case it was incorrectly set in
* png_read_start_row() by a call to png_read_update_info() or
* png_start_read_image() if png_set_interlace_handling() wasn't called
* prior to either of these functions like it should have been. You can
* only call this function once. If you desire to have an image for
* each pass of a interlaced image, use png_read_rows() instead.
*
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.8
*/
void PNGAPI
png_read_image(png_structp png_ptr, png_bytepp image)
{
png_uint_32 i, image_height;
int pass, j;
png_bytepp rp;
png_debug(1, "in png_read_image\n");
#ifdef PNG_READ_INTERLACING_SUPPORTED
pass = png_set_interlace_handling(png_ptr);
#else
if (png_ptr->interlaced)
png_error(png_ptr,
"Cannot read interlaced image -- interlace handler disabled.");
pass = 1;
#endif
image_height = png_ptr->height;
png_ptr->num_rows = image_height; /* Make sure this is set correctly */
for (j = 0; j < pass; j++) {
rp = image;
for (i = 0; i < image_height; i++) {
png_read_row(png_ptr, *rp, png_bytep_NULL);
rp++;
}
}
}
开发者ID:cafeinecake,项目名称:hge2,代码行数:45,代码来源:pngread.c
示例8: read_image_data
void read_image_data(const char* filename, png_bytep* input, png_bytep* output, size_t* w, size_t* h) {
int i;
/* Open input file */
FILE *png_input;
if((png_input = fopen("input.png", "rb")) == NULL) {
perror("Can't read input image file");
exit(1);
}
/* Read image data */
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_infop info_ptr = png_create_info_struct(png_ptr);
png_init_io(png_ptr, png_input);
png_read_info(png_ptr, info_ptr);
*w = png_get_image_width(png_ptr, info_ptr);
*h = png_get_image_height(png_ptr, info_ptr);
/* Allocate input/output memory and initialize data */
input = (png_bytep*)malloc(*h * png_get_rowbytes(png_ptr, info_ptr));
output = (png_bytep*)malloc(*h * png_get_rowbytes(png_ptr, info_ptr) * SCALE_FACTOR * SCALE_FACTOR );
for(i=0; i<*h; i++) {
png_read_row(png_ptr, *input + i * png_get_rowbytes(png_ptr, info_ptr), NULL);
}
/* Close input file */
png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
// fclose(png_input);
}
开发者ID:Leinar,项目名称:trunk,代码行数:31,代码来源:main1.cpp
示例9: read_row
/**
* \brief Reads a row of image data at a time.
*/
void read_row(byte* bytes)
{
if (setjmp(png_jmpbuf(m_png)))
{
throw error(m_error);
}
png_read_row(m_png, bytes, 0);
}
开发者ID:LRacoci,项目名称:ImageEditor,代码行数:11,代码来源:reader.hpp
示例10: throw
bool emPngImageFileModel::TryContinueLoading() throw(emString)
{
png_textp t;
int e,i,n;
if (!L->ImagePrepared) {
Image.Setup(
L->width,
L->height,
L->bytes_per_pixel
);
Signal(ChangeSignal);
L->ImagePrepared=true;
return false;
}
if (setjmp(L->jmpbuffer)) throw emString(L->errorText);
if (L->y<(int)L->height && L->pass<L->number_of_passes) {
png_read_row(
L->png_ptr,
Image.GetWritableMap()+L->y*Image.GetWidth()*Image.GetChannelCount(),
NULL
);
L->y++;
if (L->y>=(int)L->height) {
L->y=0;
L->pass++;
}
Signal(ChangeSignal);
return false;
}
png_read_end(L->png_ptr,L->end_info_ptr);
for (e=0; e<2; e++) {
n=png_get_text(
L->png_ptr,
e ? L->end_info_ptr : L->info_ptr,
&t,
NULL
);
for (i=0; i<n; i++) {
if (
t[i].text && *t[i].text && t[i].key && (
strcasecmp(t[i].key,"Comment")==0 ||
strcasecmp(t[i].key,"Description")==0
)
) {
if (!Comment.IsEmpty()) Comment+='\n';
Comment+=t[i].text;
}
}
}
Signal(ChangeSignal);
return true;
}
开发者ID:ackalker,项目名称:eaglemode,代码行数:58,代码来源:emPngImageFileModel.cpp
示例11: read_png
static int read_png ( FILE *fp ) {
png_structp png_ptr = png_create_read_struct ( PNG_LIBPNG_VER_STRING,0,0,0 );
png_infop info_ptr = NULL;
png_bytep row = NULL, display = NULL;
if ( png_ptr == NULL )
return 0;
if ( setjmp ( png_jmpbuf ( png_ptr ) ) ) {
png_destroy_read_struct ( &png_ptr, &info_ptr, NULL );
if ( row != NULL ) free ( row );
if ( display != NULL ) free ( display );
return 0;
}
png_init_io ( png_ptr, fp );
info_ptr = png_create_info_struct ( png_ptr );
if ( info_ptr == NULL )
png_error ( png_ptr, "OOM allocating info structure" );
png_read_info ( png_ptr, info_ptr );
{
png_size_t rowbytes = png_get_rowbytes ( png_ptr, info_ptr );
row = malloc ( rowbytes );
display = malloc ( rowbytes );
if ( row == NULL || display == NULL )
png_error ( png_ptr, "OOM allocating row buffers" );
{
png_uint_32 height = png_get_image_height ( png_ptr, info_ptr );
int passes = png_set_interlace_handling ( png_ptr );
int pass;
png_start_read_image ( png_ptr );
for ( pass = 0; pass < passes; ++pass ) {
png_uint_32 y = height;
/* NOTE: this trashes the row each time; interlace handling won't
* work, but this avoids memory thrashing for speed testing.
*/
while ( y-- > 0 )
png_read_row ( png_ptr, row, display );
}
}
}
/* Make sure to read to the end of the file: */
png_read_end ( png_ptr, info_ptr );
png_destroy_read_struct ( &png_ptr, &info_ptr, NULL );
free ( row );
free ( display );
return 1;
}
开发者ID:tcoupin,项目名称:rok4,代码行数:58,代码来源:timepng.c
示例12: png_read_row
const unsigned char* CImageLoaderPng::ReadRow(void *row_ptr)
{
#ifdef _engine_COMPILE_WITH_LIBPNG_
png_read_row((png_structp)row_ptr, (png_bytep)g_png_load_buffer, 0);
return (const unsigned char*)g_png_load_buffer;
#else
return 0;
#endif // _engine_COMPILE_WITH_LIBPNG_
}
开发者ID:jduranmaster,项目名称:ltegameengine,代码行数:9,代码来源:CImageLoaderPNG.cpp
示例13: read_scanline
static void read_scanline(struct oil_libpng *ol)
{
int i;
for (i=oil_scale_slots(&ol->os); i>0; i--) {
png_read_row(ol->rpng, ol->inbuf, NULL);
oil_scale_in(&ol->os, ol->inbuf);
}
}
开发者ID:ender672,项目名称:liboil,代码行数:9,代码来源:oil_libpng.c
示例14: stencilize
int stencilize (InPng *in_png, char *output_filename)
{
FILE *fh;
png_structp png;
png_infop png_info;
png_bytep row;
int i, j;
if (!(fh = fopen(output_filename, "wb"))) {
fail("failed to open output file");
}
png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
if (!png) {
fail("could not create png");
}
png_info = png_create_info_struct(png);
if (!png_info) {
fail("could not create png_info");
}
png_init_io(png, fh);
png_set_IHDR(png, png_info,
in_png->info->width,
in_png->info->height,
in_png->info->bit_depth,
in_png->info->color_type,
in_png->info->interlace_type,
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
png_write_info(png, png_info);
row = in_png->row;
for (i = 0; i < in_png->info->height; i++) {
png_read_row(in_png->png, row, NULL);
j = 0;
while (j < in_png->rowstride) {
row[j + 0] = 0;
row[j + 1] = 0;
row[j + 2] = 0;
row[j + 3] = 255 - row[j + 3];
j += 4;
}
png_write_row(png, row);
}
png_write_end(png, png_info);
fclose(fh);
return 1;
}
开发者ID:xach,项目名称:stencilizer,代码行数:56,代码来源:stencilizer.c
示例15: onSkipScanlines
bool onSkipScanlines(int count) override {
if (setjmp(png_jmpbuf(fPng_ptr))) {
SkCodecPrintf("Failed to skip row.\n");
return false;
}
for (int row = 0; row < count; row++) {
png_read_row(fPng_ptr, fSwizzlerSrcRow, nullptr);
}
return true;
}
开发者ID:sylvestre,项目名称:skia,代码行数:11,代码来源:SkPngCodec.cpp
示例16: DEBUG_ENTER_FUNC
//
// Load a texture from a png image
//
bool PngLoader::loadImageIntoBuffer() {
DEBUG_ENTER_FUNC();
if (!basicImageLoad()) {
png_destroy_read_struct(&_pngPtr, &_infoPtr, png_infopp_NULL);
return false;
}
png_set_strip_16(_pngPtr); // Strip off 16 bit channels in case they occur
if (_paletteSize) {
// Copy the palette
png_colorp srcPal = _infoPtr->palette;
for (int i = 0; i < _infoPtr->num_palette; i++) {
unsigned char alphaVal = (i < _infoPtr->num_trans) ? _infoPtr->trans[i] : 0xFF; // Load alpha if it's there
_palette->setSingleColorRGBA(i, srcPal->red, srcPal->green, srcPal->blue, alphaVal);
srcPal++;
}
} else { // Not a palettized image
if (_colorType == PNG_COLOR_TYPE_GRAY && _bitDepth < 8)
png_set_gray_1_2_4_to_8(_pngPtr); // Round up grayscale images
if (png_get_valid(_pngPtr, _infoPtr, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(_pngPtr); // Convert trans channel to alpha for 32 bits
png_set_add_alpha(_pngPtr, 0xff, PNG_FILLER_AFTER); // Filler for alpha if none exists
}
uint32 rowBytes = png_get_rowbytes(_pngPtr, _infoPtr);
// there seems to be a bug in libpng where it doesn't increase the rowbytes or the
// channel even after we add the alpha channel
if (_channels == 3 && (rowBytes / _width) == 3) {
_channels = 4;
rowBytes = _width * _channels;
}
PSP_DEBUG_PRINT("rowBytes[%d], channels[%d]\n", rowBytes, _channels);
unsigned char *line = (unsigned char*) malloc(rowBytes);
if (!line) {
png_destroy_read_struct(&_pngPtr, png_infopp_NULL, png_infopp_NULL);
PSP_ERROR("Couldn't allocate line\n");
return false;
}
for (size_t y = 0; y < _height; y++) {
png_read_row(_pngPtr, line, png_bytep_NULL);
_buffer->copyFromRect(line, rowBytes, 0, y, _width, 1); // Copy into buffer
}
free(line);
png_read_end(_pngPtr, _infoPtr);
png_destroy_read_struct(&_pngPtr, &_infoPtr, png_infopp_NULL);
return true;
}
开发者ID:project-cabal,项目名称:cabal,代码行数:57,代码来源:png_loader.cpp
示例17: png_read_row
// 读取一行png数据
bool PngReader::ReadRowData(png_bytep buffer)
{
bool result = false;
if (NULL != m_readPtr
&& NULL != m_readInfoPtr)
{
png_read_row(m_readPtr, buffer, NULL);
result = true;
}
return result;
}
开发者ID:KingsleyYau,项目名称:Dating4Man-iOS,代码行数:12,代码来源:PngReader.cpp
示例18: main
int main(int argc, char **argv)
{
int x,y;
unsigned char* image;
png_structp png_ptr_read;
png_infop info_ptr_read;
FILE *in_file, *out_file;
double gamma;
in_file=fopen("arrow.png","r");
out_file=fopen("arrow.inc","w");
if (!(in_file&&out_file)){
perror("arrow");
exit(1);
}
png_ptr_read=png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL,
NULL);
info_ptr_read=png_create_info_struct(png_ptr_read);
png_init_io(png_ptr_read, in_file);
png_read_info(png_ptr_read, info_ptr_read);
x=png_get_image_width(png_ptr_read,info_ptr_read);
y=png_get_image_height(png_ptr_read,info_ptr_read);
if (png_get_gAMA(png_ptr_read,info_ptr_read, &gamma))
{
png_set_gamma(png_ptr_read, 1, gamma);
}
else
{
png_set_gamma(png_ptr_read, 1, 1.0);
}
png_read_update_info(png_ptr_read, info_ptr_read);
image=malloc(3*x);
if (!image){
fprintf(stderr,"Not enough memory\n");
exit(1);
}
fprintf(out_file,"/* Automatically generated by the program \"arrow\" (arrow.c) */");
fprintf(out_file,"enum {arrow_width=32, arrow_height=%d, arrow_area=%d};\n",y,y*32);
fprintf(out_file,"\nstatic unsigned int arrow[%d]={\n",y+y);
for (;y;y--){
png_read_row(png_ptr_read,image,NULL);
print_row_hex(out_file,image,x);
}
fprintf(out_file,"};\n");
free(image);
png_read_end(png_ptr_read, NULL);
png_destroy_read_struct(&png_ptr_read, &info_ptr_read, NULL);
fclose(in_file);
return 0;
}
开发者ID:coolstreamtech,项目名称:cst-public-plugins-links,代码行数:54,代码来源:arrow.c
示例19: ASSERT
Raster::Line PNGRaster::GetLine(int line)
{
ASSERT(data && line >= 0 && line < data->size.cy);
byte *scanline = new byte[data->row_bytes];
if(setjmp(png_jmpbuf(data->png_ptr)))
return Raster::Line(scanline, this, true);
if(data->preload) {
delete[] scanline;
if(!data->loaded) {
data->loaded = true;
data->preimage.SetCount(data->row_bytes * data->size.cy);
data->row_pointers.Alloc(data->size.cy);
for(int i = 0; i < data->size.cy; i++)
data->row_pointers[i] = &data->preimage[i * data->row_bytes];
png_read_image(data->png_ptr, data->row_pointers);
}
const byte *rowdata = &data->preimage[data->row_bytes * line];
return Raster::Line(rowdata, this, false);
}
else {
if(line < data->next_row) {
png_destroy_read_struct(&data->png_ptr, &data->info_ptr, NULL);
GetStream().Seek(data->soff);
if(!Init()) {
NEVER();
}
if(data->strip16)
png_set_strip_16(data->png_ptr);
if(data->out_bpp > 8)
png_set_bgr(data->png_ptr);
data->next_row = 0;
}
while(data->next_row < line) {
png_read_row(data->png_ptr, scanline, NULL);
data->next_row++;
}
png_read_row(data->png_ptr, scanline, NULL);
data->next_row++;
return Raster::Line(scanline, this, true);
}
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:41,代码来源:pngupp.cpp
示例20: PNGIgnorePixels
bool PNGIgnorePixels(png_structp png, png_infop info) {
if (setjmp(png_jmpbuf(png))) {
return false;
}
unsigned height = png_get_image_height(png, info);
unsigned i;
for (i = 0; i < height; ++i) {
png_read_row(png, 0, 0);
}
return true;
}
开发者ID:Carlosamouco,项目名称:mgba,代码行数:12,代码来源:png-io.c
注:本文中的png_read_row函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论