QFCropPixelsEdit::QFCropPixelsEdit(QWidget *parent) : QWidget(parent) { lay=new QHBoxLayout(); lay->setContentsMargins(0,0,0,0); spinX1=new QSpinBox(this); spinX2=new QSpinBox(this); spinY1=new QSpinBox(this); spinY2=new QSpinBox(this); lay->addWidget(new QLabel("x = ", this)); lay->addWidget(spinX1); lay->addWidget(new QLabel(" ... ", this)); lay->addWidget(spinX2); lay->addWidget(new QLabel(" y = ", this)); lay->addWidget(spinY1); lay->addWidget(new QLabel(" ... ", this)); lay->addWidget(spinY2); setImageSize(0,1); setFullImageSize(); connectWidgets(true); setLayout(lay); }
void OverlayImageDisplay::update(float wall_dt, float ros_dt) { boost::mutex::scoped_lock(mutex_); if (!isEnabled()) { return; } if (require_update_ && is_msg_available_) { if (!overlay_) { static int count = 0; rviz::UniformStringStream ss; ss << "OverlayImageDisplayObject" << count++; overlay_.reset(new OverlayObject(ss.str())); overlay_->show(); } overlay_->updateTextureSize(msg_->width, msg_->height); // When aspect_ratio being kept, the size is specified by width; height_property_->setHidden(keep_aspect_ratio_); setImageSize(); redraw(); require_update_ = false; } if (overlay_) { overlay_->setDimensions(width_, height_); overlay_->setPosition(left_, top_); } }
bool ossimAlphaSensorHSI::initialize( const ossimAlphaSensorSupportData& supData ) { bool result = true; // Currently no error checking. ossimDpt imageSize = supData.getImageSize(); setImageSize(imageSize); setImageRect(ossimDrect(0,0,imageSize.x-1, imageSize.y-1)); setRefImgPt(ossimDpt(imageSize.x*.5, imageSize.y*.5)); setFov(supData.getFov()); setRollBias(supData.getRollBias()); setPitchBias(supData.getPitchBias()); setHeadingBias(supData.getHeadingBias()); setSlitRot(supData.getSlitRot()); setRollPoly(supData.getRollPoly()); setPitchPoly(supData.getPitchPoly()); setHeadingPoly(supData.getHeadingPoly()); setLonPoly(supData.getLonPoly()); setLatPoly(supData.getLatPoly()); setAltPoly(supData.getAltPoly()); setScanPoly(supData.getScanPoly()); updateModel(); return result; }
void USBCamera::open() { LINFO << "Capture: Trying to open USB camera."; LINFO << "Capture: (Warning) You can change the capture device with the configuration files."; try { if(!isOpened()) { m_camera->release(); m_camera->open(getDeviceNumber()); setImageSize(m_frameWidth, m_frameHeight); if(!isOpened()) { throw OpenCVException("can't open usb camera"); } } } catch(cv::Exception & ex) { throw OpenCVException(ex.msg.c_str()); } LINFO << "Capture: Succesfully opened USB camera."; }
void KisImagePyramid::setImage(KisImageWSP newImage) { if (newImage) { m_originalImage = newImage; clearPyramid(); setImageSize(m_originalImage->width(), m_originalImage->height()); retrieveImageData(m_originalImage->projection()->exactBounds()); //TODO: check whether there is needed recalculateCache() } }
VideoCapture::VideoCapture(int width, int height) { try { m_video = new cv::VideoCapture(); setImageSize(width, height); } catch(cv::Exception & ex) { throw OpenCVException(ex.msg.c_str()); } };
USBCamera::USBCamera(int width, int height) { try { m_camera = cvCaptureFromCAM(CV_CAP_ANY); setImageSize(width, height); } catch(cv::Exception & ex) { throw OpenCVException(ex.msg.c_str()); } };
Renderer::Renderer(QWidget *parent) : QWidget(parent), _camera(0), _scene(0), _raytracerThread(0), _integrator(0) { setImageSize(config->defaultImageWidth(), config->defaultImageHeight()); QTimer* updator = new QTimer(this); connect(updator, SIGNAL(timeout()), SLOT(repaint())); connect(this, SIGNAL(renderingFinished()), SLOT(_onStop())); updator->start(1000/60); _stopThread = false; _isRendering = false; _isPaused = false; }
bool PaintArea::openImage(const QString &fileName) { QImage loadedImage; if (!loadedImage.load(fileName)) return false; QSize newSize = loadedImage.size(); setImageSize(newSize.width(),newSize.height()); image = loadedImage; modified = false; update(); return true; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void WritePoleFigure::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setGoodVoxelsArrayPath(reader->readDataArrayPath("GoodVoxelsArrayPath", getGoodVoxelsArrayPath() ) ); setCrystalStructuresArrayPath(reader->readDataArrayPath("CrystalStructuresArrayPath", getCrystalStructuresArrayPath() ) ); setCellPhasesArrayPath(reader->readDataArrayPath("CellPhasesArrayPath", getCellPhasesArrayPath() ) ); setCellEulerAnglesArrayPath(reader->readDataArrayPath("CellEulerAnglesArrayPath", getCellEulerAnglesArrayPath() ) ); setImagePrefix( reader->readString("ImagePrefix", getImagePrefix())); setOutputPath( reader->readString("OutputPath", getOutputPath())); setImageFormat( reader->readValue("ImageFormat", getImageFormat())); setImageLayout( reader->readValue("ImageLayout", getImageLayout())); setImageSize( reader->readValue("ImageSize", getImageSize())); setLambertSize( reader->readValue("LambertSize", getLambertSize())); reader->closeFilterGroup(); }
//-------------------------------------------------------------------------------------------------- // Camera //-------------------------------------------------------------------------------------------------- Camera::Camera() { mpVtkCamera = vtkSmartPointer<vtkCamera>::New(); mpVtkCameraActor = vtkSmartPointer<vtkCameraActor>::New(); mpVtkCameraActor->SetCamera( mpVtkCamera ); mpVtkCameraActor->GetProperty()->SetLineWidth( 2.0 ); mpVtkCameraActor->GetProperty()->SetBackfaceCulling( 0 ); mpVtkCameraActor->GetProperty()->SetLighting( false ); setImageSize( 640.0, 480.0 ); mpPickLinesMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); mpPickLinesActor = vtkSmartPointer<vtkActor>::New(); mpPickLinesActor->SetMapper( mpPickLinesMapper ); mTotalOffset = Eigen::Vector3d::Zero(); }
void VideoCapture::open() { try { if(!isOpened()) { m_video->release(); m_video->open(getPath()); //m_video->set(CV_CAP_PROP_POS_FRAMES, 1850); setImageSize(m_frameWidth, m_frameHeight); } } catch(cv::Exception & ex) { throw OpenCVException(ex.msg.c_str()); } }
void USBCamera::setup(kerberos::StringMap &settings) { int width = std::atoi(settings.at("captures.USBCamera.frameWidth").c_str()); int height = std::atoi(settings.at("captures.USBCamera.frameHeight").c_str()); int angle = std::atoi(settings.at("captures.USBCamera.angle").c_str()); int delay = std::atoi(settings.at("captures.USBCamera.delay").c_str()); // Save width and height in settings Capture::setup(settings, width, height); setImageSize(width, height); setRotation(angle); setDelay(delay); // Initialize executor (update the usb camera at specific times). tryToUpdateCapture.setAction(this, &USBCamera::update); tryToUpdateCapture.setInterval("thrice in 10 functions calls"); }
LivePlayer::LivePlayer(QWidget *parent) : QWidget(parent), FeatureDrawer(true), mLastImage(LIVE_PLAYER_WIDTH, LIVE_PLAYER_HEIGHT, QImage::Format_RGB32), mLastPoints(0), mLastUpdate(0) { setFixedSize(LIVE_PLAYER_WIDTH, LIVE_PLAYER_HEIGHT); setImageSize(LIVE_PLAYER_WIDTH, LIVE_PLAYER_HEIGHT); setWindowTitle("Live stream classification - Copiste"); QPainter painter(&mLastImage); painter.fillRect(0,0, width(), height(), QColor(0,0,0)); painter.setFont(QFont("Arial", 25)); painter.setPen(QColor(255,255,255)); painter.drawText(0,0, width(), height(), Qt::AlignCenter, "Connecting to the server..."); update(); }
StarDetector::StarDetector(CvSize size, int n, float response_threshold, float line_threshold_projected, float line_threshold_binarized) : m_upright(NULL), m_tilted(NULL), m_flat(NULL), m_projected(NULL), m_scales(NULL), m_filter_sizes(NULL), m_nonmax(response_threshold, LineSuppressHybrid(line_threshold_projected, line_threshold_binarized)), m_filter_params(NULL) { // Pre-allocate all the memory we need setScales(n); setImageSize(size); }
void VideoCapture::setup(kerberos::StringMap &settings) { int width = std::atoi(settings.at("captures.VideoCapture.frameWidth").c_str()); int height = std::atoi(settings.at("captures.VideoCapture.frameHeight").c_str()); std::string path = settings.at("captures.VideoCapture.path"); int angle = std::atoi(settings.at("captures.VideoCapture.angle").c_str()); int delay = std::atoi(settings.at("captures.VideoCapture.delay").c_str()); // Save width and height in settings Capture::setup(settings, width, height); setImageSize(width, height); setRotation(angle); setDelay(delay); setPath(path); // Initialize video open(); }
void UIWidget::parseImageStyle(const OTMLNodePtr& styleNode) { for(const OTMLNodePtr& node : styleNode->children()) { if(node->tag() == "image-source") setImageSource(stdext::resolve_path(node->value(), node->source())); else if(node->tag() == "image-offset-x") setImageOffsetX(node->value<int>()); else if(node->tag() == "image-offset-y") setImageOffsetY(node->value<int>()); else if(node->tag() == "image-offset") setImageOffset(node->value<Point>()); else if(node->tag() == "image-width") setImageWidth(node->value<int>()); else if(node->tag() == "image-height") setImageHeight(node->value<int>()); else if(node->tag() == "image-size") setImageSize(node->value<Size>()); else if(node->tag() == "image-rect") setImageRect(node->value<Rect>()); else if(node->tag() == "image-clip") setImageClip(node->value<Rect>()); else if(node->tag() == "image-fixed-ratio") setImageFixedRatio(node->value<bool>()); else if(node->tag() == "image-repeated") setImageRepeated(node->value<bool>()); else if(node->tag() == "image-smooth") setImageSmooth(node->value<bool>()); else if(node->tag() == "image-color") setImageColor(node->value<Color>()); else if(node->tag() == "image-border-top") setImageBorderTop(node->value<int>()); else if(node->tag() == "image-border-right") setImageBorderRight(node->value<int>()); else if(node->tag() == "image-border-bottom") setImageBorderBottom(node->value<int>()); else if(node->tag() == "image-border-left") setImageBorderLeft(node->value<int>()); else if(node->tag() == "image-border") setImageBorder(node->value<int>()); else if(node->tag() == "image-auto-resize") setImageAutoResize(node->value<bool>()); } }
void KisImagePyramid::setImage(KisImageWSP newImage) { if (newImage) { m_originalImage = newImage; clearPyramid(); setImageSize(m_originalImage->width(), m_originalImage->height()); // Get the full image size QRect rc = m_originalImage->projection()->exactBounds(); KisImageConfig config; int patchWidth = config.updatePatchWidth(); int patchHeight = config.updatePatchHeight(); if (rc.width() * rc.height() <= patchWidth * patchHeight) { retrieveImageData(rc); } else { qint32 firstCol = rc.x() / patchWidth; qint32 firstRow = rc.y() / patchHeight; qint32 lastCol = (rc.x() + rc.width()) / patchWidth; qint32 lastRow = (rc.y() + rc.height()) / patchHeight; for(qint32 i = firstRow; i <= lastRow; i++) { for(qint32 j = firstCol; j <= lastCol; j++) { QRect maxPatchRect(j * patchWidth, i * patchHeight, patchWidth, patchHeight); QRect patchRect = rc & maxPatchRect; retrieveImageData(patchRect); } } } //TODO: check whether there is needed recalculateCache() } }
bool ImageBuffer::addImage(cv::Mat &image, point3D_t gpsInfo, point3D_t gpsInfoPre, float speed, float direction, int inParamIdx) { WaitForSingleObject(_hMutex,INFINITE); //int pendFlag = 0; if(!ready_flag) { if(writeIdx == 0) { bool flag = openWriteFiles(image.size()); setImageSize(image.cols, image.rows); setInParamIdx(inParamIdx); } //Buffer[writeIdx].image = image.clone(); if(writeFileFlag) { writer->write(image); fprintf(writeFp,"%.14lf,%.14lf\n",gpsInfo.lat,gpsInfo.lon); writeIdx++; bufferSize = writeIdx; if(writeIdx >= IMAGE_BUFFER_DEPTH) { writeIdx = 0; closeWriteFiles(); ready_flag = true; //printf("image buffer is full\n"); logPrintf(logLevelInfo_e,"ImageBuffer","image buffer is full!",FOREGROUND_BLUE|FOREGROUND_GREEN); } } ReleaseMutex(_hMutex); return true; } ReleaseMutex(_hMutex); return false; }
/** Add image to this selector. \param upperText Text shown above image \param lowerText Text shown under image \param image Pointer to surface to be shown \param autoResize Automatic fit size of the widget to image size */ void CAImageSelector::addImage( const std::string upperText, const std::string lowerText, CL_Texture image, bool autoResize ) { this->image[numImages].upperText = upperText; this->image[numImages].lowerText = lowerText; this->image[numImages].image = image; if( currentImage<0.0 ) { currentImage = numImages; newImage = numImages; CAImageView::image.upperText = this->image[newImage].upperText; CAImageView::image.lowerText = this->image[newImage].lowerText; } if( numImages<CA_IV_MAXIMAGES ) numImages++; if( autoResize ) { setImageSize( image.get_width(), image.get_height() ); } }
void ewol::resource::TexturedFont::init(const std::string& _fontName) { std::unique_lock<std::recursive_mutex> lock(m_mutex); ewol::resource::Texture::init(_fontName); EWOL_DEBUG("Load font : '" << _fontName << "'" ); m_font[0] = nullptr; m_font[1] = nullptr; m_font[2] = nullptr; m_font[3] = nullptr; m_modeWraping[0] = ewol::font::Regular; m_modeWraping[1] = ewol::font::Regular; m_modeWraping[2] = ewol::font::Regular; m_modeWraping[3] = ewol::font::Regular; m_lastGlyphPos[0].setValue(1,1); m_lastGlyphPos[1].setValue(1,1); m_lastGlyphPos[2].setValue(1,1); m_lastGlyphPos[3].setValue(1,1); m_lastRawHeigh[0] = 0; m_lastRawHeigh[1] = 0; m_lastRawHeigh[2] = 0; m_lastRawHeigh[3] = 0; int32_t tmpSize = 0; // extarct name and size : const char * tmpData = _fontName.c_str(); const char * tmpPos = strchr(tmpData, ':'); if (tmpPos == nullptr) { m_size = 1; EWOL_CRITICAL("Can not parse the font name : \"" << _fontName << "\" ??? ':' " ); return; } else { if (sscanf(tmpPos+1, "%d", &tmpSize)!=1) { m_size = 1; EWOL_CRITICAL("Can not parse the font name : \"" << _fontName << "\" == > size ???"); return; } } std::string localName(_fontName, 0, (tmpPos - tmpData)); if (tmpSize>400) { EWOL_ERROR("Font size too big ==> limit at 400 when exxeed ==> error : " << tmpSize << "==>30"); tmpSize = 30; } m_size = tmpSize; std::vector<std::string> folderList; if (true == ewol::getContext().getFontDefault().getUseExternal()) { #if defined(__TARGET_OS__Android) folderList.push_back("ROOT:system/fonts"); #elif defined(__TARGET_OS__Linux) folderList.push_back("ROOT:usr/share/fonts"); #endif } std::string applicationBaseFont = ewol::getContext().getFontDefault().getFolder(); std::vector<std::string> applicationBaseFontList = etk::FSNodeExplodeMultiplePath(applicationBaseFont); for (auto &it : applicationBaseFontList) { folderList.push_back(it); } for (size_t folderID=0; folderID<folderList.size() ; folderID++) { etk::FSNode myFolder(folderList[folderID]); // find the real Font name : std::vector<std::string> output; myFolder.folderGetRecursiveFiles(output); std::vector<std::string> split = etk::split(localName, ';'); EWOL_INFO("try to find font named : " << split << " in: " << myFolder); //EWOL_CRITICAL("parse string : " << split); bool hasFindAFont = false; for (size_t jjj=0; jjj<split.size(); jjj++) { EWOL_INFO(" try with : '" << split[jjj] << "'"); for (size_t iii=0; iii<output.size(); iii++) { //EWOL_DEBUG(" file : " << output[iii]); if( true == etk::end_with(output[iii], split[jjj]+"-"+"bold"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"-"+"b"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"-"+"bd"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"bold"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"bd"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"b"+".ttf", false)) { EWOL_INFO(" find Font [Bold] : " << output[iii]); m_fileName[ewol::font::Bold] = output[iii]; hasFindAFont=true; } else if( true == etk::end_with(output[iii], split[jjj]+"-"+"oblique"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"-"+"italic"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"-"+"Light"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"-"+"i"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"oblique"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"italic"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"light"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"i"+".ttf", false)) { EWOL_INFO(" find Font [Italic] : " << output[iii]); m_fileName[ewol::font::Italic] = output[iii]; hasFindAFont=true; } else if( true == etk::end_with(output[iii], split[jjj]+"-"+"bolditalic"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"-"+"boldoblique"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"-"+"bi"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"-"+"z"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"bolditalic"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"boldoblique"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"bi"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"z"+".ttf", false)) { EWOL_INFO(" find Font [Bold-Italic] : " << output[iii]); m_fileName[ewol::font::BoldItalic] = output[iii]; hasFindAFont=true; } else if( true == etk::end_with(output[iii], split[jjj]+"-"+"regular"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"-"+"r"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"regular"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+"r"+".ttf", false) || true == etk::end_with(output[iii], split[jjj]+".ttf", false)) { EWOL_INFO(" find Font [Regular] : " << output[iii]); m_fileName[ewol::font::Regular] = output[iii]; hasFindAFont=true; } } if (hasFindAFont == true) { EWOL_INFO(" find this font : '" << split[jjj] << "'"); break; } else if (jjj == split.size()-1) { EWOL_ERROR("Find NO font in the LIST ... " << split); } } if (hasFindAFont == true) { EWOL_INFO(" find this font : '" << folderList[folderID] << "'"); break; } else if (folderID == folderList.size()-1) { EWOL_ERROR("Find NO font in the LIST ... " << folderList); } } // try to find the reference mode : enum ewol::font::mode refMode = ewol::font::Regular; for(int32_t iii=3; iii >= 0; iii--) { if (m_fileName[iii].size() != 0) { refMode = (enum ewol::font::mode)iii; } } EWOL_DEBUG(" set reference mode : " << refMode); // generate the wrapping on the preventing error for(int32_t iii=3; iii >= 0; iii--) { if (m_fileName[iii].size() != 0) { m_modeWraping[iii] = (enum ewol::font::mode)iii; } else { m_modeWraping[iii] = refMode; } } for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) { if (m_fileName[iiiFontId].size() == 0) { EWOL_DEBUG("can not load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size ); m_font[iiiFontId] = nullptr; continue; } EWOL_INFO("Load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size); m_font[iiiFontId] = ewol::resource::FontFreeType::create(m_fileName[iiiFontId]); if (m_font[iiiFontId] == nullptr) { EWOL_DEBUG("error in loading FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size ); } } for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) { // set the bassic charset: m_listElement[iiiFontId].clear(); if (m_font[iiiFontId] == nullptr) { continue; } m_height[iiiFontId] = m_font[iiiFontId]->getHeight(m_size); // TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ??? setImageSize(ivec2(256,32)); // now we can acces directly on the image m_data.clear(etk::Color<>(0x00000000)); } // add error glyph addGlyph(0); // by default we set only the first AINSI char availlable for (int32_t iii=0x20; iii<0x7F; iii++) { EWOL_VERBOSE("Add clyph :" << iii); addGlyph(iii); } flush(); EWOL_DEBUG("Wrapping properties : "); EWOL_DEBUG(" " << ewol::font::Regular << " == >" << getWrappingMode(ewol::font::Regular)); EWOL_DEBUG(" " << ewol::font::Italic << " == >" << getWrappingMode(ewol::font::Italic)); EWOL_DEBUG(" " << ewol::font::Bold << " == >" << getWrappingMode(ewol::font::Bold)); EWOL_DEBUG(" " << ewol::font::BoldItalic << " == >" << getWrappingMode(ewol::font::BoldItalic)); }
// --------------------------------------------------------------------- // Driver for Packing // // Should return a 64 bit integer on a 64 bit platform. Could be fixed // later when 64-bit platforms are really available since it doesn't // affect object layout. // --------------------------------------------------------------------- NA_EIDPROC Long NAVersionedObject::drivePack(void *space, short isSpacePtr) { // ----------------------------------------------------------------- // If the object has already been packed, just convert the pointer // of the object to an offset and return its value. That value will // be used by the caller to replace the pointer stored there. // ----------------------------------------------------------------- if (isPacked()) { if (isSpacePtr) return ((Space *)space)->convertToOffset((char *)this); else return ((char *)space - (char *)this); } // ----------------------------------------------------------------- // Make sure the image size and the version ID are set properly // before proceeding on to pack the object. // ----------------------------------------------------------------- Int16 classSize = getClassSize(); if ((classSize % 8) != 0) assert((classSize % 8) == 0); setImageSize(classSize); populateImageVersionIDArray(); // ----------------------------------------------------------------- // Toggle the Endianness of the Version Header if it's not stored // in little-endian form. // // *** DON'T DO THIS JUST YET: PLAN IS TO SUPPORT THIS ONLY FROM // *** SECOND RELEASE. // ----------------------------------------------------------------- #ifndef NA_LITTLE_ENDIAN // toggleEndiannessOfVersionHeader(); #endif // ----------------------------------------------------------------- // Convert members of this object from local platform to reference // platform. // // *** DON'T DO THIS JUST YET: PLAN IS TO SUPPORT THIS ONLY FROM // *** SECOND RELEASE. // ----------------------------------------------------------------- // convertToReferencePlatform(); // ----------------------------------------------------------------- // Mark object as packed, despite it is not completely packed yet. // It is needed because the call that follows to the virtual method // pack() drives the packing of all objects referenced by this // object. If this object is subsequently referenced by another // object down the row, drivePack() will be called on this object // again. At that point of time, we should see the packed flag set // so that "double-packing" can be avoided. // ----------------------------------------------------------------- markAsPacked(); // ----------------------------------------------------------------- // pack() is a virtual method the subclass should redefine to drive // the packing of all objects it references by pointers and convert // those pointers to offsets. It should also convert the endianness // of its members to the reference if necessary. // ----------------------------------------------------------------- setIsSpacePtr( isSpacePtr !=0 ); Long offset = pack(space); // long offset = (isSpacePtr ? pack(space) : pack(space,0)); // ----------------------------------------------------------------- // Make sure the eyeCatcher_ field of the object is proper. Also // clean up the virtual table function pointer, so that the image // look identical each time. // ----------------------------------------------------------------- str_cpy_all(eyeCatcher_,VOBJ_EYE_CATCHER,VOBJ_EYE_CATCHER_SIZE); setVTblPtr(NULL); return offset; }
// // Reads the image // void PNGReader::read(ImageFile * image) { volatile unsigned char ** volatile rowPointers = NULL; png_struct * pngPtr = NULL; png_info * infoPtr = NULL; byte * data = NULL; try { int colorType, bitDepth; bool hasAlpha = false; uint bytesPerElement; ImageFormat format; unsigned long w, h; unsigned rowbytes; // Initialize the PNG library pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, pngErrorFunc, pngWarningFunc); if (unlikely(!pngPtr)) throw Exception(QString("%1: png_create_read_struct() failed").arg(m_File.fileName())); // Initialize the PNG info struct infoPtr = png_create_info_struct(pngPtr); if (unlikely(!infoPtr)) throw Exception(QString("%1: png_create_info_struct() failed").arg(m_File.fileName())); // Setup error handler if (unlikely(setjmp(png_jmpbuf(pngPtr)) != 0)) throw Exception(QString("%1: PNG decompression failed").arg(m_File.fileName())); // Setup file reading png_set_read_fn(pngPtr, &m_File, pngReadFunc); png_set_sig_bytes(pngPtr, 8); png_read_info(pngPtr, infoPtr); png_get_IHDR(pngPtr, infoPtr, &w, &h, &bitDepth, &colorType, NULL, NULL, NULL); // Setup 16 bit -> 8 bit conversion if (bitDepth > 8) png_set_strip_16(pngPtr); // Translate transparency to alpha channel if (png_get_valid(pngPtr, infoPtr, PNG_INFO_tRNS)) { png_set_tRNS_to_alpha(pngPtr); hasAlpha = true; } // Setup gamma correction double gamma; if (png_get_gAMA(pngPtr, infoPtr, &gamma)) png_set_gamma(pngPtr, 2.2, gamma); else png_set_gamma(pngPtr, 2.2, 0.45455); // We want at least 8-bit if (bitDepth < 8) { if ((colorType == PNG_COLOR_TYPE_GRAY || colorType == PNG_COLOR_TYPE_GRAY_ALPHA)) png_set_gray_1_2_4_to_8(pngPtr); else png_set_packing(pngPtr); } // Convert paletted images to RGB if (colorType == PNG_COLOR_TYPE_PALETTE) { png_set_palette_to_rgb(pngPtr); colorType = hasAlpha ? PNG_COLOR_TYPE_RGBA : PNG_COLOR_TYPE_RGB; } // Convert gray/alpha images to RGB if (colorType == PNG_COLOR_TYPE_GRAY_ALPHA || (colorType == PNG_COLOR_TYPE_GRAY && hasAlpha)) { png_set_gray_to_rgb(pngPtr); colorType = PNG_COLOR_TYPE_RGB_ALPHA; } // Add dummy alpha channel for RGB images if (colorType == PNG_COLOR_TYPE_RGB && !hasAlpha) { png_set_filler(pngPtr, 0xFF, PNG_FILLER_BEFORE); hasAlpha = true; } else if (colorType == PNG_COLOR_TYPE_RGB_ALPHA) hasAlpha = true; // Select pixel format switch (colorType) { case PNG_COLOR_TYPE_PALETTE: case PNG_COLOR_TYPE_GRAY_ALPHA: Q_ASSERT(false); // Should be handled in the code above break; case PNG_COLOR_TYPE_GRAY: bytesPerElement = 1; format = R8_UNORM; break; default: Q_ASSERT(hasAlpha); // Should be handled in the code above bytesPerElement = 4; format = RGBA8_UNORM; break; } // Re-configure PNG reading to include configured conversions png_read_update_info(pngPtr, infoPtr); rowbytes = png_get_rowbytes(pngPtr, infoPtr); // Set basic image info setImageSize(image, w, h); setImageDepth(image, 0); setImageMipLevels(image, 1); setImageFaces(image, 0); setImageFormat(image, format); setImageElementSize(image, bytesPerElement); // Allocate memory for image data data = new byte[w * h * bytesPerElement]; if (unlikely(!data)) throw Exception("Out of memory."); // Allocate array of row pointers rowPointers = new volatile unsigned char * [h]; for (unsigned j = 0; j < h; j++) rowPointers[j] = data + j * rowbytes; // Read the image png_read_image(pngPtr, (png_byte **)rowPointers); // Store image information appendImageLevelData(image, data); data = NULL; // Free memory png_destroy_read_struct(&pngPtr, &infoPtr, NULL); pngPtr = NULL; } catch (...) { delete[] rowPointers; delete[] data; if (pngPtr) { if (infoPtr) png_destroy_read_struct(&pngPtr, &infoPtr, NULL); else png_destroy_read_struct(&pngPtr, NULL, NULL); } throw; } delete[] rowPointers; }
void KisCanvas2::connectCurrentImage() { #ifdef HAVE_OPENGL if (m_d->openGLImageTextures) { connect(m_d->openGLImageTextures, SIGNAL(sigImageUpdated(const QRect &)), SLOT(updateCanvas())); connect(m_d->openGLImageTextures, SIGNAL(sigSizeChanged(qint32, qint32)), SLOT(setImageSize(qint32, qint32))); } else {
void SGMStereo::initialize(const png::image<png::rgb_pixel>& leftImage, const png::image<png::rgb_pixel>& rightImage) { setImageSize(leftImage, rightImage); allocateDataBuffer(); }
void CounterForm::slotWheelScrolledUp() { if(zoom < 3) setImageSize(1.1); }
void CqImage::loadFromFile(const std::string& fileName, TqInt imageIndex) { boost::mutex::scoped_lock lock(mutex()); boost::shared_ptr<IqTexInputFile> texFile; try { texFile = IqTexInputFile::open(fileName); if(imageIndex > 0) { IqMultiTexInputFile* multiFile = dynamic_cast<IqMultiTexInputFile*>(texFile.get()); if(multiFile && imageIndex < multiFile->numSubImages()) { multiFile->setImageIndex(imageIndex); m_imageIndex = imageIndex; } else return; } else m_imageIndex = 0; } catch(XqInternal& e) { Aqsis::log() << error << "Could not load image \"" << fileName << "\": " << e.what() << "\n"; return; } setFilename(fileName); // \todo: Should read the origin and frame size out of the image. const CqTexFileHeader& header = texFile->header(); TqUint width = header.width(); TqUint height = header.height(); setImageSize(width, height); // set size within larger cropped window const SqImageRegion displayWindow = header.find<Attr::DisplayWindow>( SqImageRegion(width, height, 0, 0) ); setFrameSize(displayWindow.width, displayWindow.height); setOrigin(displayWindow.topLeftX, displayWindow.topLeftY); // descriptive strings setDescription(header.find<Attr::Description>( header.find<Attr::Software>("No description") ).c_str()); m_realData = boost::shared_ptr<CqMixedImageBuffer>(new CqMixedImageBuffer()); texFile->readPixels(*m_realData); Aqsis::log() << Aqsis::info << "Loaded image " << fileName << " [" << width << "x" << height << " : " << texFile->header().channelList() << "]" << std::endl; fixupDisplayMap(m_realData->channelList()); // Quantize and display the data m_displayData = boost::shared_ptr<CqMixedImageBuffer>( new CqMixedImageBuffer(CqChannelList::displayChannels(), width, height)); m_displayData->initToCheckerboard(); m_displayData->compositeOver(*m_realData, m_displayMap); // Compute the effective clipping range for z-buffers updateClippingRange(); if(m_updateCallback) m_updateCallback(-1, -1, -1, -1); }
void LayoutTest::layoutToXml() const { QImage imgQt(mConfig.imagePath()); cv::Mat img = Image::qImage2Mat(imgQt); Timer dt; // find super pixels rdf::SuperPixel superPixel(img); if (!superPixel.compute()) qWarning() << "could not compute super pixel!"; QVector<QSharedPointer<Pixel> > sp = superPixel.getSuperPixels(); // find local orientation per pixel rdf::LocalOrientation lo(sp); if (!lo.compute()) qWarning() << "could not compute local orientation"; // smooth estimation rdf::GraphCutOrientation pse(sp); if (!pse.compute()) qWarning() << "could not compute set orientation"; //// find tab stops //rdf::TabStopAnalysis tabStops(sp); //if (!tabStops.compute()) // qWarning() << "could not compute text block segmentation!"; // find text lines rdf::TextLineSegmentation textLines(sp); if (!textLines.compute()) qWarning() << "could not compute text block segmentation!"; qInfo() << "algorithm computation time" << dt; // drawing cv::Mat rImg = img.clone(); // save super pixel image //rImg = superPixel.drawSuperPixels(rImg); //rImg = tabStops.draw(rImg); rImg = textLines.draw(rImg); QString dstPath = rdf::Utils::instance().createFilePath(mConfig.outputPath(), "-textlines"); rdf::Image::save(rImg, dstPath); qDebug() << "debug image saved: " << dstPath; // write XML ----------------------------------- QString loadXmlPath = rdf::PageXmlParser::imagePathToXmlPath(mConfig.imagePath()); rdf::PageXmlParser parser; parser.read(loadXmlPath); auto pe = parser.page(); pe->setCreator(QString("CVL")); pe->setImageSize(QSize(img.rows, img.cols)); pe->setImageFileName(QFileInfo(mConfig.imagePath()).fileName()); // start writing content auto ps = PixelSet::fromEdges(PixelSet::connect(sp)); if (!ps.empty()) { QSharedPointer<Region> textRegion = QSharedPointer<Region>(new Region()); textRegion->setType(Region::type_text_region); textRegion->setPolygon(ps[0]->convexHull()); for (auto tl : textLines.textLines()) { textRegion->addUniqueChild(tl); } pe->rootRegion()->addUniqueChild(textRegion); } parser.write(mConfig.xmlPath(), pe); qDebug() << "results written to" << mConfig.xmlPath(); }
FSolver::FSolver(int cols, int rows) { setImageSize(cols, rows); }
void CounterForm::slotWheelScrolledDown() { if(zoom > 0.1) setImageSize(0.9); }