本文整理汇总了C++中StreamFile::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ StreamFile::isValid方法的具体用法?C++ StreamFile::isValid怎么用?C++ StreamFile::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamFile
的用法示例。
在下文中一共展示了StreamFile::isValid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void Openchunk::run()
{
png_structp png_ptr_read;
png_infop info_ptr_read;
png_structp png_ptr_write;
png_infop info_ptr_write;
png_uint_32 next_frame_width;
png_uint_32 next_frame_height;
png_uint_32 next_frame_x_offset;
png_uint_32 next_frame_y_offset;
png_uint_16 next_frame_delay_num;
png_uint_16 next_frame_delay_den;
png_byte next_frame_dispose_op;
png_byte next_frame_blend_op;
png_color_16p Framebg;
framlist.clear();
buffer = new StreamFile();
buffer->LoadFile(subfile);
qDebug() << "### start read ->" << subfile;
if (!buffer->isValid()) {
alert("unvalid buffer fill",__LINE__);
exit(0);
}
validpng = buffer->device()->peek(4).contains("PNG");
qDebug() << "### ahed ->" << validpng;
frame1.loadFromData(buffer->stream()); /* load first frame */
if (frame1.isNull()) {
alert("unable find a valid image",__LINE__);
return;
}
png_ptr_read = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if(png_ptr_read == NULL) {
alert("unable to create read struct",__LINE__);
return;
}
info_ptr_read = png_create_info_struct(png_ptr_read);
if(info_ptr_read == NULL) {
alert("unable to create info struct",__LINE__);
return;
}
png_set_read_fn(png_ptr_read,buffer,EncoderReaderCallback);
if(setjmp(png_ptr_read->jmpbuf)) {
alert("something didn't work, jump 1",__LINE__);
return;
}
png_read_info(png_ptr_read, info_ptr_read);
if(!png_get_valid(png_ptr_read, info_ptr_read, PNG_INFO_acTL)) {
alert("source image must be animated",__LINE__);
return;
}
QRect Frect(0,0,info_ptr_read->width,info_ptr_read->height);
////////////qDebug() << "### Frame rect from head ->" << Frect;
QImage master(Frect.width(),Frect.height(),QImage::Format_ARGB32);
const uint height = master.height();
png_bytep *row_pointers = new png_bytep[height];
for (uint i = 0; i < height; ++i) {
row_pointers[i] = (png_bytep)master.scanLine(i);
}
int validloop = -1;
for(int i = 0; i < png_get_num_frames(png_ptr_read, info_ptr_read); i++)
{
/////////qDebug() << "### frame read ------------- " << i;
png_ptr_write = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if(png_ptr_write == NULL) {
alert("unable to create write struct");
return;
}
StreamFile *framer = new StreamFile();
png_set_write_fn(png_ptr_write,framer,EncoderWriteCallback, NULL);
info_ptr_write = png_create_info_struct(png_ptr_write);
if(info_ptr_write == NULL) {
alert("unable to create write struct");
return;
}
if(setjmp(png_ptr_write->jmpbuf)) {
alert("something didn't work, jump 2");
return;
}
png_read_frame_head(png_ptr_read, info_ptr_read);
if(png_get_valid(png_ptr_read, info_ptr_read, PNG_INFO_fcTL))
{
png_get_next_frame_fcTL(png_ptr_read, info_ptr_read,
&next_frame_width, &next_frame_height,
&next_frame_x_offset, &next_frame_y_offset,
&next_frame_delay_num, &next_frame_delay_den,
&next_frame_dispose_op, &next_frame_blend_op);
}
else
{
/* the first frame doesn't have an fcTL so it's expected to be hidden,
* but we'll extract it anyway next_frame_x_offset , next_frame_y_offset */
next_frame_width = png_get_image_width(png_ptr_read, info_ptr_read);
next_frame_height = png_get_image_height(png_ptr_read, info_ptr_read);
//.........这里部分代码省略.........