void djvCineonSave::open(const djvFileInfo & in, const djvImageIoInfo & info) throw (djvError) { //DJV_DEBUG("djvCineonSave::open"); //DJV_DEBUG_PRINT("in = " << in); //DJV_DEBUG_PRINT("info = " << info); _file = in; if (info.sequence.frames.count() > 1) { _file.setType(djvFileInfo::SEQUENCE); } _info = djvPixelDataInfo(); _info.size = info.size; _info.pixel = djvPixel::RGB_U10; _info.mirror.y = true; _info.endian = djvMemory::MSB; _info.align = 4; //DJV_DEBUG_PRINT("info = " << _info); _image.set(_info); }
void djvFileBrowserModel::imageLoadCallback() { //DJV_DEBUG("djvFileBrowserModel::imageLoadCallback"); QFutureWatcher<Image> * watcher = dynamic_cast<QFutureWatcher<Image> *>(sender()); const QFuture<Image> & future = watcher->future(); const Image & image = future.result(); //DJV_DEBUG_PRINT("image = " << image.image); if (image.row < _p->items.count() && image.item == &_p->items[image.row] && image.valid) { QPixmap thumbnail; try { // Scale the image. djvImage tmp(djvPixelDataInfo( image.item->thumbnailSize(), image.image.pixel())); djvOpenGlImageOptions options; options.xform.scale = djvVector2f(tmp.size()) / (djvVector2f(image.image.size() * djvPixelDataUtil::proxyScale(image.image.info().proxy))); options.colorProfile = image.image.colorProfile; if (djvFileBrowserModel::THUMBNAILS_HIGH == _p->thumbnails) { options.filter = djvOpenGlImageFilter::filterHighQuality(); } djvOpenGlImage::copy(image.image, tmp, options); thumbnail = djvPixelDataUtil::toQt(tmp); } catch (const djvError & error) { DJV_LOG("djvFileBrowserModel", djvErrorUtil::format(error).join("\n")); } _p->items[image.row].setThumbnail(thumbnail); const QModelIndex index = this->index(image.row, 0); Q_EMIT dataChanged(index, index); } watcher->deleteLater(); }
void djvDpxSave::open(const djvFileInfo & in, const djvImageIoInfo & info) throw (djvError) { //DJV_DEBUG("djvDpxSave::open"); //DJV_DEBUG_PRINT("in = " << in); //DJV_DEBUG_PRINT("info = " << info); _file = in; if (info.sequence.frames.count() > 1) { _file.setType(djvFileInfo::SEQUENCE); } _info = djvPixelDataInfo(); _info.size = info.size; _info.mirror.y = true; switch (_options.endian) { case djvDpxPlugin::ENDIAN_AUTO: break; case djvDpxPlugin::ENDIAN_MSB: _info.endian = djvMemory::MSB; break; case djvDpxPlugin::ENDIAN_LSB: _info.endian = djvMemory::LSB; break; default: break; } switch (_options.type) { case djvDpxPlugin::TYPE_U10: _info.pixel = djvPixel::RGB_U10; break; default: { djvPixel::TYPE type = djvPixel::type(info.pixel); switch (type) { case djvPixel::F16: case djvPixel::F32: type = djvPixel::U16; break; default: break; } _info.pixel = djvPixel::pixel(djvPixel::format(info.pixel), type); } break; } switch (djvPixel::bitDepth(_info.pixel)) { case 8: case 10: _info.align = 4; break; } //DJV_DEBUG_PRINT("info = " << _info); _image.set(_info); }
void djvIffSave::open(const djvFileInfo & in, const djvImageIoInfo & info) throw (djvError) { //DJV_DEBUG("djvIffSave::open"); //DJV_DEBUG_PRINT("in = " << in); _file = in; if (info.sequence.frames.count() > 1) { _file.setType(djvFileInfo::SEQUENCE); } _info = djvPixelDataInfo(); _info.size = info.size; _info.endian = djvMemory::MSB; djvPixel::FORMAT format = djvPixel::format(info.pixel); switch (format) { case djvPixel::L: format = djvPixel::RGB; break; case djvPixel::LA: format = djvPixel::RGBA; break; default: break; } djvPixel::TYPE type = djvPixel::type(info.pixel); switch (type) { case djvPixel::U10: case djvPixel::F16: case djvPixel::F32: type = djvPixel::U16; break; default: break; } _info.pixel = djvPixel::pixel(format, type); _info.endian = djvMemory::MSB; //DJV_DEBUG_PRINT("info = " << _info); _image.set(_info); }
void djvViewMagnifyTool::pixelDataUpdate() { //DJV_DEBUG("djvViewMagnifyTool::pixelDataUpdate"); djvSignalBlocker signalBlocker(QObjectList() << _p->widget); djvPixelData tmp(djvPixelDataInfo( _p->widget->width(), _p->widget->height(), djvPixel::RGB_U8)); if (const djvPixelData * data = viewWidget()->data()) { //DJV_DEBUG_PRINT("data = " << *data); const double zoom = djvMath::pow(2, _p->zoom); djvVector2i pick = djvVectorUtil::floor<double, int>( djvVector2f(_p->pick - viewWidget()->viewPos()) * zoom - djvVector2f(tmp.info().size) / 2.0); //DJV_DEBUG_PRINT("zoom = " << zoom); //DJV_DEBUG_PRINT("pick = " << pick); try { viewWidget()->makeCurrent(); if (! _p->magnifyBuffer || _p->magnifyBuffer->info() != tmp.info()) { _p->magnifyBuffer.reset(new djvOpenGlOffscreenBuffer(tmp.info())); } djvOpenGlImageOptions options = viewWidget()->options(); options.xform.position -= pick; options.xform.scale *= zoom * viewWidget()->viewZoom(); if (! _p->colorProfile) { options.colorProfile = djvColorProfile(); } if (! _p->displayProfile) { options.displayProfile = djvViewDisplayProfile(); } djvOpenGlImage::copy( *data, tmp, options, &_p->magnifyState, _p->magnifyBuffer.data()); _p->widget->setPixmap( djvPixmapUtil::toQt( tmp, djvOpenGlImageOptions(), &_p->convertState, _p->convertBuffer.data())); } catch (djvError error) { error.add( djvViewUtil::errorLabels()[djvViewUtil::ERROR_MAGNIFY]); context()->printError(error); } } //_p->widget->setPixelData(tmp); _p->pixelDataInit = false; }
void djvOpenGlTest::members() { DJV_DEBUG("djvOpenGlTest::members"); djvImageContext context; QScopedPointer<djvOpenGlContext> openGlContext( context.openGlContextFactory()->create()); djvOpenGlContextScope contextScope(openGlContext.data()); QScopedPointer<djvOpenGlOffscreenBuffer> buffer( new djvOpenGlOffscreenBuffer(djvPixelDataInfo(100, 100, djvPixel::RGBA_U8))); djvOpenGlOffscreenBufferScope bufferScope(buffer.data()); DJV_DEBUG_PRINT("buffer = " << buffer->info()); DJV_DEBUG_PRINT("buffer id = " << buffer->id()); DJV_DEBUG_PRINT("buffer texture = " << buffer->texture()); { djvOpenGlUtil::ortho(djvVector2i(100, 100)); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); djvOpenGlUtil::color(djvColor(0.5)); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); djvOpenGlUtil::drawBox(djvBox2i(25, 25, 50, 50)); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); djvOpenGlUtil::drawBox(djvBox2f(50.0, 50.0, 50.0, 50.0)); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); djvVector2f uv[4] = { djvVector2f(0.0, 0.0), djvVector2f(0.1, 0.0), djvVector2f(0.1, 1.0), djvVector2f(0.0, 1.0) }; djvOpenGlUtil::drawBox(djvBox2i(25, 25, 50, 50), uv); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); djvOpenGlUtil::drawBox(djvBox2f(50.0, 50.0, 50.0, 50.0), uv); DJV_ASSERT(GL_NO_ERROR == ::glGetError()); } { for (int i = 0; i < djvPixel::PIXEL_COUNT; ++i) { DJV_ASSERT(djvOpenGlUtil::format(static_cast<djvPixel::PIXEL>(i))); DJV_ASSERT(djvOpenGlUtil::type(static_cast<djvPixel::PIXEL>(i))); } } }
void djvOpenGlImage::draw( const djvPixelData & data, const djvOpenGlImageOptions & options, djvOpenGlImageState * state) throw (djvError) { //DJV_DEBUG("djvOpenGlImage::draw"); //DJV_DEBUG_PRINT("data = " << data); //DJV_DEBUG_PRINT("color profile = " << options.colorProfile); RestoreState restoreState; djvOpenGlImageState defaultState; if (! state) { state = &defaultState; } const djvPixelDataInfo & info = data.info(); const int proxyScale = options.proxyScale ? djvPixelDataUtil::proxyScale(info.proxy) : 1; const djvVector2i scale = djvVectorUtil::ceil<double, int>( options.xform.scale * djvVector2f(info.size * proxyScale)); const djvVector2i scaleTmp(scale.x, data.h()); //DJV_DEBUG_PRINT("scale = " << scale); //DJV_DEBUG_PRINT("scale tmp = " << scaleTmp); // Initialize. const djvOpenGlImageFilter::FILTER filter = info.size == scale ? djvOpenGlImageFilter::NEAREST : (djvVectorUtil::area(scale) < djvVectorUtil::area(info.size) ? options.filter.min : options.filter.mag); //DJV_DEBUG_PRINT("filter min = " << options.filter.min); //DJV_DEBUG_PRINT("filter mag = " << options.filter.mag); //DJV_DEBUG_PRINT("filter = " << filter); if (! state->_init || state->_info != info || state->_options != options) { switch (filter) { case djvOpenGlImageFilter::NEAREST: case djvOpenGlImageFilter::LINEAR: { //DJV_DEBUG_PRINT("init single pass"); state->_texture->init( data.info(), djvOpenGlImageFilter::toGl(filter), djvOpenGlImageFilter::toGl(filter)); state->_shader->init( sourceVertex, sourceFragment( options.colorProfile.type, options.displayProfile, options.channel, false, 0, false)); } break; case djvOpenGlImageFilter::BOX: case djvOpenGlImageFilter::TRIANGLE: case djvOpenGlImageFilter::BELL: case djvOpenGlImageFilter::BSPLINE: case djvOpenGlImageFilter::LANCZOS3: case djvOpenGlImageFilter::CUBIC: case djvOpenGlImageFilter::MITCHELL: { //DJV_DEBUG_PRINT("init two pass"); state->_texture->init( data.info(), GL_NEAREST, GL_NEAREST); // Initialize horizontal pass. djvPixelData contrib; scaleContrib( data.w(), scale.x, filter, contrib); state->_scaleXContrib->init( contrib, GL_NEAREST, GL_NEAREST); state->_scaleXShader->init( sourceVertex, sourceFragment( options.colorProfile.type, djvOpenGlImageDisplayProfile(), static_cast<djvOpenGlImageOptions::CHANNEL>(0), true, contrib.h(), true)); // Initialize vertical pass. scaleContrib( data.h(), scale.y, filter, contrib); state->_scaleYContrib->init( contrib, GL_NEAREST, GL_NEAREST); state->_scaleYShader->init( sourceVertex, sourceFragment( static_cast<djvColorProfile::PROFILE>(0), options.displayProfile, options.channel, true, contrib.h(), false)); } break; default: break; } state->_init = true; state->_info = info; state->_options = options; } // Render. const djvPixelDataInfo::Mirror mirror( info.mirror.x ? (! options.xform.mirror.x) : options.xform.mirror.x, info.mirror.y ? (! options.xform.mirror.y) : options.xform.mirror.y); //DJV_DEBUG_PRINT("mirror = " << mirror.x << " " << mirror.y); switch (filter) { case djvOpenGlImageFilter::NEAREST: case djvOpenGlImageFilter::LINEAR: { //DJV_DEBUG_PRINT("draw single pass"); state->_shader->bind(); // Initialize color and display profiles. colorProfileInit( options, state->_shader->program(), *state->_lutColorProfile); displayProfileInit( options, state->_shader->program(), *state->_lutDisplayProfile); // Draw. activeTexture(GL_TEXTURE0); uniform1i(state->_shader->program(), "inTexture", 0); state->_texture->copy(data); state->_texture->bind(); DJV_DEBUG_OPEN_GL(glPushMatrix()); const djvMatrix3f m = djvOpenGlImageXform::xformMatrix(options.xform); //DJV_DEBUG_PRINT("m = " << m); DJV_DEBUG_OPEN_GL(glLoadMatrixd(djvMatrixUtil::matrix4(m).e)); quad(info.size, mirror, proxyScale); DJV_DEBUG_OPEN_GL(glPopMatrix()); } break; case djvOpenGlImageFilter::BOX: case djvOpenGlImageFilter::TRIANGLE: case djvOpenGlImageFilter::BELL: case djvOpenGlImageFilter::BSPLINE: case djvOpenGlImageFilter::LANCZOS3: case djvOpenGlImageFilter::CUBIC: case djvOpenGlImageFilter::MITCHELL: { //DJV_DEBUG_PRINT("draw two pass"); // Horizontal pass. djvOpenGlOffscreenBuffer buffer( djvPixelDataInfo(scaleTmp, data.pixel())); { djvOpenGlOffscreenBufferScope bufferScope(&buffer); state->_scaleXShader->bind(); colorProfileInit( options, state->_scaleXShader->program(), *state->_lutColorProfile); activeTexture(GL_TEXTURE0); uniform1i(state->_scaleXShader->program(), "inTexture", 0); state->_texture->copy(data); state->_texture->bind(); activeTexture(GL_TEXTURE1); uniform1i( state->_scaleXShader->program(), "inScaleContrib", 1); state->_scaleXContrib->bind(); glPushAttrib(GL_TRANSFORM_BIT | GL_VIEWPORT_BIT); glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); djvOpenGlUtil::ortho(scaleTmp); glViewport(0, 0, scaleTmp.x, scaleTmp.y); quad(scaleTmp, mirror); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glPopAttrib(); } // Vertical pass. state->_scaleYShader->bind(); displayProfileInit( options, state->_scaleYShader->program(), *state->_lutDisplayProfile); activeTexture(GL_TEXTURE0); uniform1i(state->_scaleYShader->program(), "inTexture", 0); DJV_DEBUG_OPEN_GL(glBindTexture(GL_TEXTURE_2D, buffer.texture())); activeTexture(GL_TEXTURE1); uniform1i(state->_scaleYShader->program(), "inScaleContrib", 1); state->_scaleYContrib->bind(); djvOpenGlImageXform xform = options.xform; xform.scale = djvVector2f(1.0); const djvMatrix3f m = djvOpenGlImageXform::xformMatrix(xform); DJV_DEBUG_OPEN_GL(glPushMatrix()); DJV_DEBUG_OPEN_GL(glLoadMatrixd(djvMatrixUtil::matrix4(m).e)); quad(scale); DJV_DEBUG_OPEN_GL(glPopMatrix()); } break; default: break; } }
void djvFFmpegSave::open(const djvFileInfo & fileInfo, const djvImageIoInfo & info) throw (djvError) { //DJV_DEBUG("djvFFmpegSave::open"); //DJV_DEBUG_PRINT("fileInfo = " << fileInfo); //DJV_DEBUG_PRINT("info = " << info); close(); _frame = 0; // Open the file. djvPixel::PIXEL pixel = static_cast<djvPixel::PIXEL>(0); bool bgr = false; QString avFormatName; AVCodecID avCodecId = static_cast<AVCodecID>(0); AVPixelFormat avPixel = static_cast<AVPixelFormat>(0); double avQScale = -1.0; _avFrameRgbPixel = static_cast<AVPixelFormat>(0); djvFFmpeg::Dictionary dictionary; QString value; switch (_options.format) { /*case djvFFmpeg::H264: pixel = djvPixel::RGBA_U8; avFormatName = "mov"; avCodecId = AV_CODEC_ID_H264; switch (_options.quality) { case djvFFmpeg::LOW: value = "fast"; break; case djvFFmpeg::MEDIUM: value = "medium"; break; case djvFFmpeg::HIGH: value = "slow"; break; default: break; } av_dict_set( dictionary(), "preset", value.toLatin1().data(), 0); break;*/ case djvFFmpeg::MPEG4: pixel = djvPixel::RGBA_U8; bgr = info.bgr; avFormatName = "mp4"; avCodecId = AV_CODEC_ID_MPEG4; avPixel = AV_PIX_FMT_YUV420P; _avFrameRgbPixel = bgr ? AV_PIX_FMT_BGRA : AV_PIX_FMT_RGBA; switch (_options.quality) { case djvFFmpeg::LOW: avQScale = 9.0; break; case djvFFmpeg::MEDIUM: avQScale = 3.0; break; case djvFFmpeg::HIGH: avQScale = 1.0; break; default: break; } break; case djvFFmpeg::PRO_RES: pixel = djvPixel::RGB_U16; bgr = info.bgr; avFormatName = "mov"; avCodecId = AV_CODEC_ID_PRORES; avPixel = AV_PIX_FMT_YUV422P10; _avFrameRgbPixel = bgr ? AV_PIX_FMT_RGB48 : AV_PIX_FMT_BGR48; switch (_options.quality) { case djvFFmpeg::LOW: value = "1"; break; case djvFFmpeg::MEDIUM: value = "2"; break; case djvFFmpeg::HIGH: value = "3"; break; default: break; } av_dict_set( dictionary(), "profile", value.toLatin1().data(), 0); break; case djvFFmpeg::MJPEG: pixel = djvPixel::RGBA_U8; bgr = info.bgr; avFormatName = "mov"; avCodecId = AV_CODEC_ID_MJPEG; avPixel = AV_PIX_FMT_YUVJ422P; _avFrameRgbPixel = bgr ? AV_PIX_FMT_BGRA : AV_PIX_FMT_RGBA; switch (_options.quality) { case djvFFmpeg::LOW: avQScale = 9.0; break; case djvFFmpeg::MEDIUM: avQScale = 3.0; break; case djvFFmpeg::HIGH: avQScale = 1.0; break; default: break; } break; default: break; } //DJV_DEBUG_PRINT("pixel = " << pixel); //DJV_DEBUGBUG_PRINT("av format name = " << avFormatName); //DJV_DEBUGBUG_PRINT("av codec id = " << avCodecId); //DJV_DEBUGBUG_PRINT("av pixel = " << avPixel); //DJV_DEBUGBUG_PRINT("av rgb pixel = " << _avFrameRgbPixel); //DJV_DEBUGBUG_PRINT("av qscale = " << avQScale); AVOutputFormat * avFormat = av_guess_format( avFormatName.toLatin1().data(), 0, //fileInfo.fileName().toLatin1().data(), 0); if (! avFormat) { throw djvError( djvFFmpeg::staticName, qApp->translate("djvFFmpegSave", "Cannot find format: %1"). arg(djvFFmpeg::formatLabels()[_options.format])); } //DJV_DEBUGBUG_PRINT("av format extensions = " << avFormat->extensions); _avFormatContext = avformat_alloc_context(); _avFormatContext->oformat = avFormat; AVCodec * avCodec = avcodec_find_encoder(avCodecId); if (! avCodec) { throw djvError( djvFFmpeg::staticName, qApp->translate("djvFFmpegSave", "Cannot find encoder: %1"). arg(djvFFmpeg::formatLabels()[_options.format])); } AVCodecContext * avCodecContext = avcodec_alloc_context3(avCodec); avcodec_get_context_defaults3(avCodecContext, avCodec); //DJV_DEBUGBUG_PRINT("default bit rate = " << avCodecContext->bit_rate); //DJV_DEBUGBUG_PRINT("default gop = " << avCodecContext->gop_size); avCodecContext->pix_fmt = avPixel; avCodecContext->width = info.size.x; avCodecContext->height = info.size.y; avCodecContext->time_base.den = info.sequence.speed.scale(); avCodecContext->time_base.num = info.sequence.speed.duration(); if (avFormat->flags & AVFMT_GLOBALHEADER) avCodecContext->flags |= CODEC_FLAG_GLOBAL_HEADER; if (avQScale >= 0.0) { avCodecContext->flags |= CODEC_FLAG_QSCALE; avCodecContext->global_quality = FF_QP2LAMBDA * avQScale; } int r = avcodec_open2(avCodecContext, avCodec, dictionary()); if (r < 0) { throw djvError( djvFFmpeg::staticName, djvFFmpeg::toString(r)); } _avStream = avformat_new_stream(_avFormatContext, avCodecContext->codec); if (! _avStream) { throw djvError( djvFFmpeg::staticName, qApp->translate("djvFFmpegSave", "Cannot create stream")); } _avStream->codec = avCodecContext; _avStream->time_base.den = info.sequence.speed.scale(); _avStream->time_base.num = info.sequence.speed.duration(); r = avio_open2( &_avIoContext, fileInfo.fileName().toLatin1().data(), AVIO_FLAG_READ_WRITE, 0, 0); if (r < 0) { throw djvError( djvFFmpeg::staticName, djvFFmpeg::toString(r)); } _avFormatContext->pb = _avIoContext; r = avformat_write_header(_avFormatContext, 0); if (r < 0) { throw djvError( djvFFmpeg::staticName, djvFFmpeg::toString(r)); } _info = djvPixelDataInfo(); _info.fileName = fileInfo; _info.size = info.size; _info.pixel = pixel; _info.bgr = info.bgr; // Initialize the buffers. _image.set(_info); _avFrame = av_frame_alloc(); _avFrame->width = info.size.x; _avFrame->height = info.size.y; _avFrame->format = avCodecContext->pix_fmt; _avFrameBuf = (uint8_t *)av_malloc( avpicture_get_size( avCodecContext->pix_fmt, avCodecContext->width, avCodecContext->height)); avpicture_fill( (AVPicture *)_avFrame, _avFrameBuf, avCodecContext->pix_fmt, avCodecContext->width, avCodecContext->height); _avFrameRgb = av_frame_alloc(); // Initialize the software scaler. _swsContext = sws_getContext( info.size.x, info.size.y, _avFrameRgbPixel, avCodecContext->width, avCodecContext->height, avCodecContext->pix_fmt, SWS_BILINEAR, 0, 0, 0); if (! _swsContext) { throw djvError( djvFFmpeg::staticName, qApp->translate("djvFFmpegSave", "Cannot create software scaler")); } }
void djvColorProfileTest::operators() { DJV_DEBUG("djvColorProfileTest::operators"); { djvColorProfile a, b; a.type = b.type = djvColorProfile::LUT; a.gamma = b.gamma = 1.0; a.lut = b.lut = djvPixelData(djvPixelDataInfo(16, 1, djvPixel::L_U8)); a.exposure = b.exposure = djvColorProfile::Exposure(1.0, 2.0, 3.0, 4.0); a.lut.zero(); b.lut.zero(); DJV_ASSERT(a.exposure == b.exposure); DJV_ASSERT(a.exposure != djvColorProfile::Exposure()); DJV_ASSERT(a == b); DJV_ASSERT(a != djvColorProfile()); } { djvColorProfile::Exposure exposure; QStringList s = QStringList() << "1.0" << "2.0" << "3.0" << "4.0"; s >> exposure; DJV_ASSERT(djvMath::fuzzyCompare(1.0, exposure.value)); DJV_ASSERT(djvMath::fuzzyCompare(2.0, exposure.defog)); DJV_ASSERT(djvMath::fuzzyCompare(3.0, exposure.kneeLow)); DJV_ASSERT(djvMath::fuzzyCompare(4.0, exposure.kneeHigh)); } { djvColorProfile::Exposure exposure(1.0, 2.0, 3.0, 4.0); QStringList s; s << exposure; DJV_ASSERT((QStringList() << "1" << "2" << "3" << "4") == s); } { const djvColorProfile::Exposure a(1.0, 2.0, 3.0, 4.0); QStringList tmp; tmp << a; djvColorProfile::Exposure b; tmp >> b; DJV_ASSERT(a == b); } { const djvColorProfile::PROFILE a = djvColorProfile::LUT; QStringList tmp; tmp << a; djvColorProfile::PROFILE b = static_cast<djvColorProfile::PROFILE>(0); tmp >> b; DJV_ASSERT(a == b); } { DJV_DEBUG_PRINT(djvColorProfile::Exposure()); DJV_DEBUG_PRINT(djvColorProfile::RAW); DJV_DEBUG_PRINT(djvColorProfile()); } }
void djvOpenGlImageTest::members() { DJV_DEBUG("djvOpenGlImageTest::members"); { DJV_DEBUG_PRINT(djvOpenGlImageXform::xformMatrix(djvOpenGlImageXform())); } { DJV_DEBUG_PRINT(djvOpenGlImageColor::brightnessMatrix(1.0, 0.0, 0.0)); DJV_DEBUG_PRINT(djvOpenGlImageColor::contrastMatrix(1.0, 0.0, 0.0)); DJV_DEBUG_PRINT(djvOpenGlImageColor::saturationMatrix(1.0, 0.0, 0.0)); DJV_DEBUG_PRINT(djvOpenGlImageColor::colorMatrix(djvOpenGlImageColor())); } { DJV_DEBUG_PRINT(djvOpenGlImageLevels::colorLut(djvOpenGlImageLevels(), 0.5)); } { DJV_ASSERT(djvOpenGlImageFilter::toGl(djvOpenGlImageFilter::NEAREST)); DJV_ASSERT(djvOpenGlImageFilter::toGl(djvOpenGlImageFilter::LINEAR)); DJV_ASSERT(!djvOpenGlImageFilter::toGl(djvOpenGlImageFilter::BOX)); } { djvImageContext context; QScopedPointer<djvOpenGlContext> openGlContext( context.openGlContextFactory()->create()); djvOpenGlContextScope contextScope(openGlContext.data()); for (int i = 0; i < djvPixel::PIXEL_COUNT; ++i) { const djvPixel::PIXEL pixel = static_cast<djvPixel::PIXEL>(i); DJV_DEBUG_PRINT("pixel = " << pixel); djvPixelData a(djvPixelDataInfo(1, 1, pixel)), b(djvPixelDataInfo(1, 1, pixel)); djvColor color(pixel); djvColorUtil::convert(djvColor(0.5), color); DJV_DEBUG_PRINT("color = " << color); djvMemory::copy(color.data(), a.data(), a.dataByteCount()); DJV_DEBUG_PRINT("pixel = " << djvOpenGlImage::pixel(a, 0, 0)); djvOpenGlImage::copy(a, b); DJV_DEBUG_PRINT("compare = " << (a == b)); djvOpenGlImage::average(a, color); DJV_DEBUG_PRINT("average = " << color); djvColor min, max; djvOpenGlImage::histogram(a, b, 1, min, max); DJV_DEBUG_PRINT("histogram = " << b); DJV_DEBUG_PRINT("min = " << min); DJV_DEBUG_PRINT("max = " << max); DJV_DEBUG_PRINT(""); } } }
void djvRlaLoad::_open(const QString & in, djvImageIoInfo & info, djvFileIo & io) throw (djvError) { //DJV_DEBUG("djvRlaLoad::_open"); //DJV_DEBUG_PRINT("in = " << in); // Open the file. io.setEndian(djvMemory::endian() != djvMemory::MSB); io.open(in, djvFileIo::READ); // Read the header. Header header; //DJV_DEBUG_PRINT("header size = " << static_cast<int>(sizeof(Header))); io.get(&header, sizeof(Header)); if (io.endian()) { endian(&header); } debug(header); const int w = header.active[1] - header.active[0] + 1; const int h = header.active[3] - header.active[2] + 1; // Read the scanline table. _rleOffset.setSize(h); io.get32(_rleOffset(), h); // Get file information. const djvVector2i size(w, h); djvPixel::PIXEL pixel = static_cast<djvPixel::PIXEL>(0); if (header.matteChannels > 1) { throw djvError( djvRla::staticName, djvImageIo::errorLabels()[djvImageIo::ERROR_UNSUPPORTED]); } if (header.matteChannelType != header.colorChannelType) { throw djvError( djvRla::staticName, djvImageIo::errorLabels()[djvImageIo::ERROR_UNSUPPORTED]); } if (header.matteBitDepth != header.colorBitDepth) { throw djvError( djvRla::staticName, djvImageIo::errorLabels()[djvImageIo::ERROR_UNSUPPORTED]); } if (! djvPixel::pixel( header.colorChannels + header.matteChannels, header.colorBitDepth, 3 == header.colorChannelType ? djvPixel::FLOAT : djvPixel::INTEGER, pixel)) { throw djvError( djvRla::staticName, djvImageIo::errorLabels()[djvImageIo::ERROR_UNSUPPORTED]); } if (header.field) { throw djvError( djvRla::staticName, djvImageIo::errorLabels()[djvImageIo::ERROR_UNSUPPORTED]); } info = djvPixelDataInfo(in, size, pixel); }