void TSpriteIcon::draw(gcn::Graphics *graphics){ if( (sprite_ != NULL) && (!frames_.empty()) ){ setImage( frames_.at(sprite_->getFrameProgression()) ); } gcn::Icon::draw(graphics); }
caRelatedDisplay::caRelatedDisplay(QWidget *parent) : caRowColMenu(parent) { setImage("fileopen.png"); setStacking(Row); replacemodes << "false" << "false" << "false" << "false" << "false" << "false" << "false" << "false" << "false" << "false"<< "false" << "false" << "false" << "false" << "false" << "false"; }
bool NAMFFmpegImageStream::open(const std::string & filename) { setFileName(filename); if (! m_decoder->open(filename)) return false; //setImage( // m_decoder->video_decoder().width(), m_decoder->video_decoder().height(), 1, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, // const_cast<unsigned char *>(m_decoder->video_decoder().image()), NO_DELETE //); // OpenCV Image creation //cvNamedWindow( "Test", 0 ); //cvResizeWindow("Test", m_decoder->video_decoder().width(), m_decoder->video_decoder().height()); // According to previous line the number of channels is 4: RGBA _nbChannels = 4; _opencvImage = cvCreateImage(cvSize(m_decoder->video_decoder().width(), m_decoder->video_decoder().height()), IPL_DEPTH_8U, _nbChannels); //TEST createIplImageFromGLimage(const_cast<unsigned char *>(m_decoder->video_decoder().image())); process(_opencvImage); //OpenCV_to_OSG(_opencvImage,this); setImage( m_decoder->video_decoder().width(), m_decoder->video_decoder().height(), 1, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, (unsigned char*)(_opencvImage->imageData), NO_DELETE ); /*setImage( m_decoder->video_decoder().width(), m_decoder->video_decoder().height(), 1, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, //(unsigned char*)(_opencvImage->imageData), NO_DELETE _movieImage->data(),NO_DELETE );*/ // END TEST setPixelAspectRatio(m_decoder->video_decoder().pixelAspectRatio()); OSG_NOTICE<<"ffmpeg::open("<<filename<<") size("<<s()<<", "<<t()<<") aspect ratio "<<m_decoder->video_decoder().pixelAspectRatio()<<std::endl; #if 1 // swscale is reported errors and then crashing when rescaling video of size less than 10 by 10. if (s()<=10 || t()<=10) return false; #endif m_decoder->video_decoder().setUserData(this); m_decoder->video_decoder().setPublishCallback(publishNewFrame); /*if (m_decoder->audio_decoder().validContext()) { OSG_NOTICE<<"Attaching FFmpegAudioStream"<<std::endl; getAudioStreams().push_back(new osgFFmpeg::FFmpegAudioStream(m_decoder.get())); }*/ _status = PAUSED; applyLoopingMode(); start(); // start thread return true; }
CacheReadResponder(const LLUUID& id, LLImageFormatted* image) : mFormattedImage(image), mID(id) { setImage(image); }
void Sprite::applyImage(std::string theImage) { setImage(anImage); }
void ImageNode::setImage(float height, const Image& image, const Rect& imageRegion) noexcept { setImage(image, imageRegion); setHeight(height); }
UpcomingEventsWidget::UpcomingEventsWidget( const LastFmEventPtr &event, QGraphicsItem *parent, Qt::WindowFlags wFlags ) : QGraphicsWidget( parent, wFlags ) , m_mapButton( 0 ) , m_urlButton( 0 ) , m_image( new QLabel ) , m_event( event ) { setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum ); m_image->setText( i18n("Loading picture...") ); m_image->setAttribute( Qt::WA_NoSystemBackground ); m_image->setAlignment( Qt::AlignCenter ); m_image->setFixedSize( 128, 128 ); QGraphicsProxyWidget *imageProxy = new QGraphicsProxyWidget( this ); imageProxy->setWidget( m_image ); m_attendance = createLabel(); m_date = createLabel(); m_location = createLabel(); m_name = createLabel(); m_participants = createLabel(); m_tags = createLabel(); m_venue = createLabel(); QGraphicsLinearLayout *buttonsLayout = new QGraphicsLinearLayout( Qt::Horizontal ); buttonsLayout->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed ); if( event && event->venue() && event->venue()->location ) { QPointF geo( event->venue()->location->longitude, event->venue()->location->latitude ); if( !geo.isNull() ) { m_mapButton = new Plasma::PushButton( this ); m_mapButton->setMaximumSize( QSizeF( 22, 22 ) ); m_mapButton->setIcon( KIcon("edit-find") ); // TODO: a map icon would be nice m_mapButton->setToolTip( i18n( "View map" ) ); buttonsLayout->addItem( m_mapButton ); } } if( event && event->url().isValid() ) { m_urlButton = new Plasma::PushButton( this ); m_urlButton->setMaximumSize( QSizeF( 22, 22 ) ); m_urlButton->setIcon( KIcon("applications-internet") ); m_urlButton->setToolTip( i18n( "Open Last.fm webpage for this event" ) ); connect( m_urlButton, SIGNAL(clicked()), this, SLOT(openUrl()) ); buttonsLayout->addItem( m_urlButton ); } QSizePolicy::Policy minPol = QSizePolicy::Minimum; QGraphicsWidget *supportLabel, *venueLabel, *locationLabel, *dateLabel, *attendLabel, *tagsLabel; supportLabel = createLabel( i18nc("@label:textbox Supporing acts for an event", "Supporting:"), minPol ); venueLabel = createLabel( i18nc("@label:textbox", "Venue:"), minPol ); locationLabel = createLabel( i18nc("@label:textbox", "Location:"), minPol ); dateLabel = createLabel( i18nc("@label:textbox", "Date:"), minPol ); attendLabel = createLabel( i18nc("@label:textbox", "Attending:"), minPol ); tagsLabel = createLabel( i18nc("@label:textbox", "Tags:"), minPol ); QGraphicsGridLayout *infoLayout = new QGraphicsGridLayout; infoLayout->addItem( supportLabel, 0, 0 ); infoLayout->addItem( venueLabel, 1, 0 ); infoLayout->addItem( locationLabel, 2, 0 ); infoLayout->addItem( dateLabel, 3, 0 ); infoLayout->addItem( attendLabel, 4, 0 ); infoLayout->addItem( tagsLabel, 5, 0 ); infoLayout->addItem( m_participants, 0, 1 ); infoLayout->addItem( m_venue, 1, 1 ); infoLayout->addItem( m_location, 2, 1 ); infoLayout->addItem( m_date, 3, 1 ); infoLayout->addItem( m_attendance, 4, 1 ); infoLayout->addItem( m_tags, 5, 1 ); QGraphicsGridLayout *layout = new QGraphicsGridLayout; layout->addItem( imageProxy, 0, 0, 2, 1, Qt::AlignCenter ); layout->addItem( m_name, 0, 1 ); layout->addItem( buttonsLayout, 0, 2, Qt::AlignRight ); layout->addItem( infoLayout, 1, 1, 1, 2 ); setLayout( layout ); QString name = event->name(); if( event->isCancelled() ) name = i18nc( "@label:textbox Title for a canceled upcoming event", "<s>%1</s> (Canceled)", name ); setName( name ); setDate( event->date() ); setLocation( event->venue()->location ); setVenue( event->venue() ); setAttendance( event->attendance() ); setParticipants( event->participants() ); setTags( event->tags() ); setImage( event->imageUrl(LastFmEvent::Large) ); }
void QImageItem::resetImage() { setImage(QImage()); }
void NovelLayer::playNext() { // 次のアクションセット取得 auto actions = this->_player->popNextActions(); if (actions->empty() || actions == NULL) { // アクションが無いのでシーン終了 this->endScene(); } else { int rootActionIdx = this->beginAction(); // 取得したアクションを実行する for (auto action : *actions) { switch (action->getType()) { case NovelAction::Type::Set: setImage(action); break; case NovelAction::Type::Name: setNameImage(action); break; case NovelAction::Type::Speak: case NovelAction::Type::Narration: this->updateSpeechBalloon(action); break; case NovelAction::Type::Delay: this->playDelay(action); break; case NovelAction::Type::Shake: break; case NovelAction::Type::Wait: this->playWait(); break; case NovelAction::Type::Clear: this->clearBalloons(); break; case NovelAction::Type::ShowImage: this->showItem(action, true); break; case NovelAction::Type::ShowImageInstant: this->showItem(action, false); break; case NovelAction::Type::HideImage: this->hideItem(true); break; case NovelAction::Type::HideImageInstant: this->hideItem(false); break; case NovelAction::Type::Music: if (action->getValue() == "fadeout") { SoundManager::getInstance()->fadeOutBgm(1.0f); } else { SoundManager::getInstance()->playBgm(action->getValue()); } break; case NovelAction::Type::Effect: SoundManager::getInstance()->playEffect(action->getValue()); break; default: break; } } this->completeAction(rootActionIdx); } }
Heightmap::Heightmap(string path) { setImage(path); setTriangleSize(4.0, 40.0, 4.0); }
void ImageLoader::elementWillMoveToNewOwnerDocument() { setImage(0); }
Heightmap::Heightmap() { setImage(""); setTriangleSize(4.0, 40.0, 4.0); }
Heightmap::Heightmap(string path, float tw, float th, float td) { setImage(path); setTriangleSize(tw, th, td); }
void FileGrabForeground::draw(DrawActionBase *action, Viewport *port) { if(getActive() == false) return; if(getName().empty()) { FWARNING(("FileGrabForeground::draw: no name ?!?\n")); return; } Image::PixelFormat pixelFormat = (Image::PixelFormat)getPixelFormat(); pixelFormat = (pixelFormat == 0) ? Image::OSG_RGB_PF : pixelFormat; // do we have an image yet? If not, create one. if(getImage() == NullFC) { beginEditCP(this->getPtr(), FileGrabForeground::ImageFieldMask); { ImagePtr iPtr = Image::create(); iPtr->set(pixelFormat, 1); setImage(iPtr); } endEditCP (this->getPtr(), FileGrabForeground::ImageFieldMask); } else if(getImage()->getPixelFormat() != pixelFormat) { ImagePtr iPtr = getImage(); beginEditCP(iPtr, Image::PixelFormatFieldMask); { iPtr->reformat(pixelFormat); } endEditCP (iPtr, Image::PixelFormatFieldMask); } // read pixels Inherited::draw(action,port); Char8 *name = new Char8 [ getName().size() + 32 ]; // this is really // arbitrary... :( sprintf(name, getName().c_str(), getFrame()); ImagePtr i = getImage(); i->write(name); delete [] name; if(getIncrement() != false) { beginEditCP(this->getPtr(), FileGrabForeground::FrameFieldMask); { setFrame(getFrame() + 1); } endEditCP (this->getPtr(), FileGrabForeground::FrameFieldMask); } }
void OSCollapsibleItemHeader::setExpanded(bool expanded) { m_expanded = expanded; setImage(m_expanded); }
KisImagePyramid::~KisImagePyramid() { setImage(0); }
void ImageNode::setImage(const Size& size, const Image& image, const Rect& imageRegion) noexcept { setImage(image, imageRegion); setSize(size); }
void CMyPaintDoc::clear() { resetHistory(); setImage(NULL); setFileImage(); }
void ImageLoader::elementDidMoveToNewDocument() { setImage(0); }
void Sheep::directionChanged(Direction newDir) { setImage(imageCache[(int)newDir]); }
void STDCALL printNewStatsPageTwo(int currentPage) { if (!D2isLODGame()) return D2PrintStatsPage(); WCHAR text[BUFSIZE]; LPWSTR lpText; bDontPrintBorder = false; Unit* ptChar = D2GetClientPlayer(); d2_assert(!ptChar, "Printing stats page : no character selected",__FILE__,__LINE__); d2_assert(ptChar->nUnitType != UNIT_PLAYER, "Printing stats page : bad unit type",__FILE__,__LINE__); //Init data for print image sDrawImageInfo data; ZeroMemory(&data,sizeof(data)); //print background fillRect(RX(0),RY(480),320,432,0,5);//552 setImage(&data, newStatsInterfaceImages); setFrame(&data, 0); D2PrintImage(&data, RX(0), RY(224), -1, 5, 0); setFrame(&data, 1); D2PrintImage(&data, RX(256),RY(224), -1, 5, 0);//256 setFrame(&data, 2); D2PrintImage(&data, RX(0), RY(48), -1, 5, 0);//432 setFrame(&data, 3); D2PrintImage(&data, RX(256),RY(48), -1, 5, 0); D2SetFont(1); for (int i=0; i<nbStatsInterface; i++) manageStatLine(ptChar, &statsInterface[i], currentPage, text); /* // DWORD x,y; // DWORD curValue; // CharStatsBIN* charStats = D2GetCharStatsBIN(ptChar->nPlayerClass); // DifficultyLevelsBIN* difficultyLevels = D2GetDifficultyLevelsBIN (D2GetDifficultyLevel()); //print deadly Strike / Critical Strike x=RX(25); y=RY(445); Unit* ptItem = D2GetSkillItem(ptChar); DWORD cs = ptItem ? D2GetCriticalStrikeFromMasteries(ptChar,ptItem,0,2) : 0; cs = cs>100?100:cs; cs += D2GetPlayerStat(ptChar, STATS_PASSIVE_CRITICAL_STRIKE, 0)*(100-cs)/100; cs = cs>100?100:cs; //SkillDescBIN* skilldesc = SgptDataTables->skilldesc + 9; LPWSTR lpCS = D2GetStringFromIndex(skilldesc->strNameID); lpText = D2GetStringFromIndex(getDescStrPos(STATS_ITEM_DEADLYSTRIKE)); curValue = D2GetPlayerStat(ptChar, STATS_ITEM_DEADLYSTRIKE, 0); cs += curValue*(100-cs)/100; curValue = cs>100?100:cs; swprintf(text,L"%i%% %s/%s",curValue,lpCS,lpText); D2SetFont(1); D2SetFont( D2GetPixelLen(text)>0x110 ? 6 : 1); D2PrintString(text, x, y, WHITE, 0); */ //print background previous/next page buttons setImage(&data, statsBackgroundImages); setFrame(&data, D2GetResolution()?1:0); D2PrintImage(&data, getXPreviousPageBtn()-7, getYPreviousPageBtn()+8, -1, 5, 0); //print button close setImage(&data, D2LoadBuySelBtn()); setFrame(&data, 10 + isDownBtn.close); D2PrintImage(&data, getXCloseBtn(), getYCloseBtn(), -1, 5, 0); //print previous page button setFrame(&data, 12 + isDownBtn.previousPage); D2PrintImage(&data, getXPreviousPageBtn(), getYPreviousPageBtn(), -1, 5, 0); //print next page button setFrame(&data, 14 + isDownBtn.nextPage); D2PrintImage(&data, getXNextPageBtn(), getYNextPageBtn(), -1, 5, 0); //////////////////// POPUP PRINTING //////////////////// //set MouseX & MouseY DWORD mx = D2GetMouseX(); DWORD my = D2GetMouseY(); D2SetFont(1); if (isOnCloseBtn(mx,my)) // print popup "close" { D2PrintPopup(D2GetStringFromIndex(0x1030), getXCloseBtn()+getLCloseBtn()/2, getYCloseBtn()-getHCloseBtn(), WHITE, 1); } else if (isOnPreviousPageBtn(mx,my)) //print popup "previous page" { lpText = getLocalString(STR_PREVIOUS_PAGE); D2PrintPopup(lpText, getXPreviousPageBtn()+getLPreviousPageBtn()/2, getYPreviousPageBtn()-getHPreviousPageBtn(), WHITE, 1); } else if (isOnNextPageBtn(mx,my)) //print popup "next page" { lpText = getLocalString(STR_NEXT_PAGE); D2PrintPopup(lpText, getXNextPageBtn()+getLNextPageBtn()/2, getYNextPageBtn()-getHNextPageBtn(), WHITE, 1); } }
void BonusBall::setType(BonusType bt) { bonusType_ = bt; setImage(findFileName(bt)); }
bool Cluster::update() { if (!Node::update()) return false; if (!isDirty(this, 40)) return true; boost::timer t1; cv::Mat in = getImage("in"); if (in.empty()) return false; const bool use_manhat = getSignal("manhat") > 0.5; float max_space_dist = (in.cols*in.cols + in.rows*in.rows); if (use_manhat) max_space_dist = (in.cols + in.rows); cv::Mat out = in.clone(); /* if (has_initted) { has_initted = true; } */ const float margin = getSignal("margin"); const float upper = 1.0 + margin; const float lower = 1.0 - margin; const float dist_weight = getSignal("dist_weight"); int num = getSignal("num"); // 1 just tracks the average color of the image if (num < 1) num = 1; // TBD arbitrary maximum if (num > 10) num = 10; const int old_size = clusters.size(); clusters.resize(num); std::vector<cluster_center> nc; nc.resize(clusters.size()); for (int k = 0; k < nc.size(); k++) { initCluster(nc[k], in.cols, in.rows); if (k >= old_size) { initCluster(clusters[k], in.cols, in.rows, true); LOG(INFO) << k << " " << old_size << " " << nc.size() << ", " << clusters[k].x; } } const bool wrap = getSignal("wrap") > 0.5; const int wd = in.cols; const int ht = in.rows; for (int y = 0; y < in.rows; ++y) { for (int x = 0; x < in.cols; ++x) { cv::Vec4b src2 = in.at<cv::Vec4b> (y,x); float dist = max_space_dist; int dist_ind = 0; // search through all clusters for nearest one for (int k = 0; k < clusters.size(); k++) { struct cluster_center cc = clusters[k]; int x2 = x; int y2 = y; if (wrap) { float dx = cc.x - x2; float dy = cc.y - y2; if (dx + wd < -dx) x2 -= wd; else if ( -(dx - wd) < dx) x2 += wd; if (dy + ht < - y2) y2 -= ht; else if ( -(dy - ht) < dy) y2 += ht; } // There might be an inevitable amount of oscillation in wrap mode where // points that might be within range in multiple directions // will flip-flop between them. // could try to smooth motion of colors and centers const float span_x = (cc.max_x - cc.min_x)*(upper)+10; const float span_y = (cc.max_y - cc.min_y)*upper; const int mid_x = (cc.max_x + cc.min_x)/2; const int mid_y = (cc.max_y + cc.min_y)/2; if ((x2 < mid_x + span_x/2) && (x2 > mid_x - span_x/2) && (y2 < mid_y + span_y/2) && (y2 > mid_y - span_y/2)) { const float kdist = find_dist( src2.val[0], src2.val[1], src2.val[2], x2, y2, cc.rgb.val[0], cc.rgb.val[1], cc.rgb.val[2], cc.x, cc.y, max_space_dist, dist_weight, use_manhat); //in.cols, in.rows); //, //wrap); //, inst->color_weight); // store the closest match if (kdist < dist) { dist = kdist; dist_ind = k; } } } // clusters // update min maxes if (x > nc[dist_ind].max_x) nc[dist_ind].max_x = x; if (x < nc[dist_ind].min_x) nc[dist_ind].min_x = x; if (y > nc[dist_ind].max_y) nc[dist_ind].max_y = y; if (y < nc[dist_ind].min_y) nc[dist_ind].min_y = y; nc[dist_ind].aggr_x += x; nc[dist_ind].aggr_y += y; nc[dist_ind].aggr_r += src2.val[0]; nc[dist_ind].aggr_g += src2.val[1]; nc[dist_ind].aggr_b += src2.val[2]; nc[dist_ind].numpix += 1.0; // use the old cluster center color out.at<cv::Vec4b>(y,x) = clusters[dist_ind].rgb; // TBD optionally provide a scaled image that encodes distance from centers //out.at<cv::Vec4b>(y,x) = cv::Vec4b(dist*1024, dist*512, // dist*256, 0); // clusters[dist_ind].rgb.val[2],0); }} // xy loop throug input image setImage("out", out); //setSignal("num", nc.size()); /// update cluster_centers for (int k = 0; k < nc.size(); k++) { if (nc[k].numpix > 0) { nc[k].x = (int) (nc[k].aggr_x/nc[k].numpix); nc[k].y = (int) (nc[k].aggr_y/nc[k].numpix); nc[k].rgb = cv::Vec4b( (unsigned char) (nc[k].aggr_r/nc[k].numpix), (unsigned char) (nc[k].aggr_g/nc[k].numpix), (unsigned char) (nc[k].aggr_b/nc[k].numpix), 0 ); } setSignal("x" + boost::lexical_cast<std::string>(k), nc[k].x); setSignal("y" + boost::lexical_cast<std::string>(k), nc[k].y); if (false) { setSignal("mnx" + boost::lexical_cast<std::string>(k), nc[k].min_x); setSignal("mny" + boost::lexical_cast<std::string>(k), nc[k].min_y); setSignal("mxx" + boost::lexical_cast<std::string>(k), nc[k].max_x); setSignal("mxy" + boost::lexical_cast<std::string>(k), nc[k].max_y); } setSignal("r" + boost::lexical_cast<std::string>(k), nc[k].rgb.val[0]); setSignal("g" + boost::lexical_cast<std::string>(k), nc[k].rgb.val[1]); setSignal("b" + boost::lexical_cast<std::string>(k), nc[k].rgb.val[2]); setSignal("p" + boost::lexical_cast<std::string>(k), nc[k].numpix); } clusters = nc; //setSignal("time", t1.elapsed()); }
Creator::Creator(QWidget *parent) : QWidget(parent) { _modifier = 0; qRegisterMetaType<MessageLevel>("MessageLevel"); qRegisterMetaType<cv::Mat>("cv::Mat"); qRegisterMetaType<CalibrationSet>("CalibrationSet"); qRegisterMetaType<QMatrix4x4>("QMatrix4x4"); qRegisterMetaType<PositionDesc>("PositionDesc"); ui.setupUi(this); // populate values to comboboxes ui.modifierCombo->addItem("None", QVariant(NoneModifier)); ui.modifierCombo->addItem("Canny", QVariant(CannyModifier)); // connections // Global application // shortcuts _shortcuts.push_back(new QShortcut(QKeySequence("Ctrl+s"), this)); _shortcuts.push_back(new QShortcut(QKeySequence("Alt+a"), this)); _shortcuts.push_back(new QShortcut(QKeySequence("Alt+n"), this)); connect(_shortcuts[0], SIGNAL(activated()), this, SLOT(SaveSettings())); connect(_shortcuts[1], SIGNAL(activated()), this, SLOT(AddPoint())); connect(_shortcuts[2], SIGNAL(activated()), this, SLOT(AddNewPoint())); // worker connects connect(this, SIGNAL(modeChangedSignal(int)), _capturer.GetWorker(), SLOT(SetMode(int))); connect(ui.renderer, SIGNAL( DescChangedSignal(PositionDesc&)), this, SLOT(FillActive(PositionDesc&))); // rendered connects connect(ui.renderGroup, SIGNAL(buttonClicked(int)), ui.renderer, SLOT(ChangeRenderStyle(int))); ui.renderGroup->setId(ui.renderPointsButton, RenderPoints); ui.renderGroup->setId(ui.renderWireframeButton, RenderWireframe); ui.renderGroup->setId(ui.renderFullButton, RenderComplete); connect(ui.loadButton, SIGNAL(clicked()), this, SLOT(LoadModel())); connect(ui.renderer, SIGNAL(reportSignal(MessageLevel, const QString &)), ui.infobox, SLOT(Report(MessageLevel, const QString&))); connect(ui.reloadShadersButton, SIGNAL(clicked()), ui.renderer, SLOT(ChangeShaders())); connect(ui.lockGroup, SIGNAL(buttonClicked(int)), ui.renderer, SLOT(ChangeActiveKeyPos(int))); ui.lockGroup->setId(ui.cameraRadioButton, PositionCamera); ui.lockGroup->setId(ui.modelRadioButton, PositionModel); ui.lockGroup->setId(ui.lightRadioButton, PositionLight); // videorender connections connect(ui.applyDescButton, SIGNAL(clicked()), this, SLOT(ChangeActiveDesc())); connect(ui.saveSettingsButton, SIGNAL(clicked(void)), this, SLOT(SaveSettings())); connect(ui.playButton, SIGNAL(clicked(void)), this, SLOT(PlayVideo())); connect(ui.pauseButton, SIGNAL(clicked(void)), this, SLOT(Pause(void))); connect(ui.cloudPoints, SIGNAL(Finished(void)), this, SLOT(EnablePlay())); connect(ui.cloudPoints, SIGNAL(reportSignal(MessageLevel, const QString &)), ui.infobox, SLOT(Report(MessageLevel, const QString&))); connect(ui.createMeshButton, SIGNAL(clicked()),this, SLOT(StartCreating())); //connect(ui.nextFrameButton, SIGNAL(clicked(void)), ui.cloudPoints, SLOT(RequestNextFrame())); //connect(ui.prevFrameButton, SIGNAL(clicked(void)), ui.cloudPoints, SLOT(RequestPrevFrame())); ui.nextFrameButton->setDisabled(true); ui.prevFrameButton->setDisabled(true); connect(ui.stopButton, SIGNAL(clicked(void)), this, SLOT(Stop(void))); connect(ui.featuresCheckbox, SIGNAL(clicked(void)), this, SLOT(FeaturesFromFrame())); connect(ui.stopButton, SIGNAL(clicked(void)), this, SLOT(Stop())); connect(ui.greyCheckBox, SIGNAL(clicked(void)), this, SLOT(ShowGreyFrame(void))); connect(ui.newButton, SIGNAL(clicked(void)), this, SLOT(CreateNew(void))); //calibration connects connect(ui.loadCalibrationButton, SIGNAL(clicked()), this, SLOT(LoadCalibration(void))); connect(ui.runCalibrationButton, SIGNAL(clicked()), this, SLOT(RunCalibration(void))); connect(ui.calibrationFolderButton, SIGNAL(clicked()), this, SLOT(LoadCalibrationImages())); connect(ui.applyCalibrationButton, SIGNAL(clicked()), this, SLOT(SendParameters())); connect(ui.playUndistortedButton, SIGNAL(clicked()), this, SLOT(ShowUndistorted())); connect(ui.saveCalibrationButton, SIGNAL(clicked()), this, SLOT(SaveCalibration())); connect(&_capturer, SIGNAL(imageReadySignal(cv::Mat)), ui.cloudPoints, SLOT(setImage(cv::Mat))); connect(&_capturer, SIGNAL(reportSignal(MessageLevel, const QString &)), ui.cloudPoints, SLOT(Report(MessageLevel, const QString &))); connect(_capturer.GetWorker(), SIGNAL(camParametersSignal(cv::Mat, cv::Mat)), ui.cloudPoints, SLOT(ShowParameters(cv::Mat, cv::Mat))); connect(ui.cloudPoints, SIGNAL(setCalibrationSignal(CalibrationSet)), _capturer.GetWorker(), SLOT(ChangeCalibration(CalibrationSet))); // comparer connects connect(ui.compareNext, SIGNAL(clicked()), this, SLOT(GetNextImagePair())); connect(this, SIGNAL(PreparePairSignal(int, int)), _capturer.GetWorker(), SLOT(PreparePair(int,int))); connect(_capturer.GetWorker(), SIGNAL(imagePairSignal(cv::Mat, cv::Mat)), this, SLOT(SetCompare(cv::Mat, cv::Mat))); connect(ui.applyModifierButton, SIGNAL(clicked()), this, SLOT(SetModifier())); //connect(ui.comparePrev, SIGNAL(clicked()), this, SLOT(GetPrevImagePair())); // rest of the initialization LoadSettings(); }
bool ImageView::checkAndStartLoader(const QString &filename) { int cidx; cidx = m_flist->findPath(filename); if (cidx<0) return false; ImageItem *found[IV_MAX_QUEUE_SIZE+1]; memset(found, 0, sizeof(found)); ImageItem *ptr, *todel; int qidx; bool hasLoading = false; ptr = m_loadQueue; while (ptr) { todel = ptr; ptr = ptr->m_next; if (todel->m_status==ImageItem::LOADING) { hasLoading = true; } qidx = m_flist->findPath(todel->m_filename); if (qidx>=cidx && qidx<=cidx+IV_MAX_QUEUE_SIZE) { found[qidx-cidx] = todel; } else { printf("ImageView::check drop %s\n", (const char*)todel->m_filename.utf8()); delete todel; } } m_loadQueue = NULL; m_queueSize = 0; ImageItem **last = &m_loadQueue; bool to_return = false; if (found[0]) { switch (found[0]->m_status) { case ImageItem::LOADED: setImage(found[0]->m_image, found[0]->m_splits); delete found[0]; repaint(false); printf("ImageView::check : FOUND LOADED (%s)\n", (const char*)filename.utf8()); to_return = true; break; case ImageItem::LOADING: m_image = (QPixmap)NULL; found[0]->m_status = ImageItem::WAITING; *last = found[0]; last = &(*last)->m_next; m_queueSize += 1; repaint(false); printf("ImageView::check : FOUND LOADING (%s)\n", (const char*)filename.utf8()); to_return = true; break; default: case ImageItem::FAILED: delete found[0]; to_return = false; break; } } /* restore loading queue */ int idx; for (idx=1 ; idx<IV_MAX_QUEUE_SIZE+1 ; idx++) { if (found[idx]) { *last = found[idx]; last = &(*last)->m_next; m_queueSize += 1; } else { if (!hasLoading) { QString filename = m_flist->getFile(cidx+idx); if (!filename.isNull()) { *last = new ImageItem(filename); last = &(*last)->m_next; hasLoading = true; m_queueSize += 1; m_bgLock.lock(); m_cmd = IVLC_LOAD; m_cmdFile = filename; m_bgLock.signal(); m_bgLock.unlock(); } } } } *last = NULL; return to_return; }
void vtImage::_CreateFromDIB(vtDIB *pDIB, bool b16bit) { int i, w, h, bpp; char *data; w = pDIB->GetWidth(); h = pDIB->GetHeight(); bpp = pDIB->GetDepth(); data = (char *) pDIB->GetDIBData(); int SizeImage = w * h * (bpp / 8); GLubyte *image = new GLubyte[SizeImage]; #if 1 memcpy(image, data, SizeImage); #else // Flip the orientation of the image: a DIB is stored bottom-up, but // OSG and OpenGL expect the bitmap to be top-down. // (Why is this not required?? It should be, but it works correctly // if we don't do the flip.) int SizeRow = w * (bpp / 8); for (i = 0; i < h; i++) memcpy(image + i * SizeRow, data + (h-1-i) * SizeRow, SizeRow); #endif int z; int pixelFormat = GL_RGB; GLubyte tmp; if ( bpp == 24 ) { z = 3; /* BGR --> RGB */ for (i = 0; i < w * h; i++) { tmp = image [ 3 * i ]; image [ 3 * i ] = image [ 3 * i + 2 ]; image [ 3 * i + 2 ] = tmp; } pixelFormat = GL_RGB; } else if ( bpp == 32 ) { z = 4; /* BGRA --> RGBA */ for (i = 0; i < w * h; i++ ) { tmp = image [ 4 * i ]; image [ 4 * i ] = image [ 4 * i + 2 ]; image [ 4 * i + 2 ] = tmp; } pixelFormat = GL_RGBA; } else if ( bpp == 8 ) { pixelFormat = GL_LUMINANCE; } int internalFormat; if (b16bit) internalFormat = GL_RGB5; // use specific else internalFormat = pixelFormat; // use default setImage(w, h, 1, // s, t, r internalFormat, // int internalFormat, pixelFormat, // uint pixelFormat, GL_UNSIGNED_BYTE, // uint dataType, image, osg::Image::USE_NEW_DELETE); }
void ImageLoader::elementDidMoveToNewDocument() { clearFailedLoadURL(); setImage(0); }
bool vtImage::_ReadPNG(const char *filename) { FILE *fp = NULL; uchar header[8]; png_structp png; png_infop info; png_infop endinfo; png_bytep *row_p; png_uint_32 width, height; int depth, color; png_uint_32 i; png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png) { // We compiled against the headers of one version of libpng, but // linked against the libraries from another version. If you get // this, fix the paths in your development environment. return false; } info = png_create_info_struct(png); endinfo = png_create_info_struct(png); fp = vtFileOpen(filename, "rb"); if (fp && fread(header, 1, 8, fp) && png_check_sig(header, 8)) png_init_io(png, fp); else { png_destroy_read_struct(&png, &info, &endinfo); return false; } png_set_sig_bytes(png, 8); png_read_info(png, info); png_get_IHDR(png, info, &width, &height, &depth, &color, NULL, NULL, NULL); if (color == PNG_COLOR_TYPE_GRAY || color == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb(png); // never strip alpha // { // png_set_strip_alpha(png); // color &= ~PNG_COLOR_MASK_ALPHA; // } // Always expand paletted images if (color == PNG_COLOR_TYPE_PALETTE) png_set_expand(png); /*--GAMMA--*/ // checkForGammaEnv(); double screenGamma = 2.2 / 1.0; #if 0 // Getting the gamma from the PNG file is disabled here, since // PhotoShop writes bizarre gamma values like .227 (PhotoShop 5.0) // or .45 (newer versions) double fileGamma; if (png_get_gAMA(png, info, &fileGamma)) png_set_gamma(png, screenGamma, fileGamma); else #endif png_set_gamma(png, screenGamma, 1.0/2.2); png_read_update_info(png, info); m_pPngData = (png_bytep) malloc(png_get_rowbytes(png, info)*height); row_p = (png_bytep *) malloc(sizeof(png_bytep)*height); bool StandardOrientation = true; for (i = 0; i < height; i++) { if (StandardOrientation) row_p[height - 1 - i] = &m_pPngData[png_get_rowbytes(png, info)*i]; else row_p[i] = &m_pPngData[png_get_rowbytes(png, info)*i]; } png_read_image(png, row_p); free(row_p); int iBitCount; switch (color) { case PNG_COLOR_TYPE_GRAY: case PNG_COLOR_TYPE_RGB: case PNG_COLOR_TYPE_PALETTE: iBitCount = 24; break; case PNG_COLOR_TYPE_GRAY_ALPHA: case PNG_COLOR_TYPE_RGB_ALPHA: iBitCount = 32; break; default: return false; } png_read_end(png, endinfo); png_destroy_read_struct(&png, &info, &endinfo); // Don't free the data, we're going to pass it to OSG // free(m_pPngData); if (fp) fclose(fp); int pixelFormat; uint internalFormat; if (iBitCount == 24) pixelFormat = GL_RGB; else if (iBitCount == 32) pixelFormat = GL_RGBA; if (m_internalformat == -1) internalFormat = pixelFormat; // use default else internalFormat = m_internalformat; // use specific setImage(width, height, 1, internalFormat, // int internalFormat, pixelFormat, // uint pixelFormat GL_UNSIGNED_BYTE, // uint dataType m_pPngData, osg::Image::USE_MALLOC_FREE); return true; }
int main() //Declare and initialize Variables inside main function { char fileName[BUFFER_SIZE]; int i,j,rows,cols,user_input=0,Value1=0,loop=1; char ci; //Print out menu while (loop = 1){ // printf("Please select an option:\n"); // printf("1) Read in a picture file and process it.\n"); // printf("2) Read in two picture files and subtract the second picture from the first.\n"); printf("Read in a pic and apply the sobelfunc function to it. Use a grayscale pic saved as a *.pgm in your computer Please enter the number 3 on your keyboard and then hit the enter key \n"); // printf("4) Exit.\n"); scanf("%d", &user_input); //Read in an image and prompt user to enter a value for the image if (user_input == 1){ printf("enter image filename in the format *.pgm: "); scanf("%s", fileName); img = readpic(fileName); printf("Successfully read image file '%s'\n", fileName); printf("Enter a value for the picture: "); scanf("%d", &Value1); system("pause"); F3(img, numRows, numCols, Value1); F4(img, numRows, numCols, Value1); printf("Enter image filename for output: "); scanf("%s", fileName); writeoutpic(fileName,img); free(img); img = NULL; } //Read in two images and subtract the second from the first else if (user_input == 2) { printf("Enter first image filename: "); scanf("%s", fileName); // temppicx = readpic(fileName); printf("Enter second image filename: "); scanf("%s", fileName); // temppicy = readpic(fileName); // sobelout = setImage(); // subtractpixels(sobelout, temppicx, temppicy); printf("Enter image filename for output: "); scanf("%s", fileName); // writeoutpic(fileName,sobelout); free(temppicx); temppicx = NULL; free(temppicy); temppicy = NULL; } //Read in a picture and apply the sobelfunc function to it else if (user_input == 3){ printf("Enter pic filename (*.pgm, example dog.pgm): "); scanf("%s", fileName); img = readpic(fileName); sobelout= setdImage(); candid = setImage(); sobelout= setdImage(); temppicx= setdImage(); temppicy= setdImage(); finaly= setImage(); sobelout2=setImage(); cannyfunc(img,sobelout,temppicx,temppicy,candid,finaly); printf("Enter mag filename for output: "); scanf("%s", fileName); for(i=0;i<numRows;i++) for (j=0;j<numCols;j++) sobelout2[i][j]= (int) sobelout[i][j]; writeoutpic(fileName,sobelout2); printf("Enter peaks filename for output: "); scanf("%s", fileName); writeoutpic(fileName,candid); printf("Enter final filename for output: "); scanf("%s", fileName); writeoutpic(fileName,finaly); free(img); img = NULL; } //Exit the program. else if (user_input == 4) { return(EXIT_SUCCESS); } } }
void ImageLoader::elementDidMoveToNewDocument() { if (m_loadDelayCounter) m_loadDelayCounter->documentChanged(m_element->document()); clearFailedLoadURL(); setImage(0); }