MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { undoStack = new QUndoStack(this); createActions(); createMenus(); createToolBars(); createStatusBar(); createCentralWidget(); createDockWindows(); #ifndef QT_NO_DEBUG createUndoView(); #endif connect(pipelineWidget, SIGNAL(sourceCodeChanged(QString)), codeWidget, SLOT(setPlainText(QString))); connect(pipelineWidget, SIGNAL(outputPixmapChanged(QPixmap)), imageWidget, SLOT(updatePixmap(QPixmap))); setWindowTitle("Prototyping Toolkit for Image Processing"); loadImageFile(":/Images/lena.jpg"); resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5); }
Gosu::Image::Image(Graphics& graphics, const std::wstring& filename, bool tileable) { // Forward. Bitmap bmp; loadImageFile(bmp, filename); Image(graphics, bmp, tileable).data.swap(data); }
void Pixels32Import::import_loadFrom(const char* filename){ long width=0; long height=0; TImageHandleImport image=loadImageFile(filename,&width,&height); this->resizeFast(width,height); drawImage(m_data.user_data,image); deleteImageHandle(image); }
HVSTGFX::CSprite::CSprite(char *fileName, bool image) { loaded = false; sprite = loadImageFile(fileName, &imgFile, texture); FreeImage_Unload(imgFile.dib); width = tempWidth; height = tempHeight; }
Gosu::Image::Image(Graphics& graphics, const std::wstring& filename, unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight, bool tileable) { // Forward. Bitmap bmp; loadImageFile(bmp, filename); Image(graphics, bmp, srcX, srcY, srcWidth, srcHeight, tileable).data.swap(data); }
void portThread_doFileTask( a243q_asynDriver_t* p_asynLink ) { struct imageAnalysisResult localResult; size_t imageSize = 0; int imageWidth = 0; int imageHeight = 0; int result; /* read the file */ /* we are here, because: */ /* (!strncmp( p_asynLink->p_url, "file:", 5 )) */ const char* p_fileName = p_asynLink->p_url + 5; memset( &localResult, 0, sizeof(localResult) ); /* we ignore changes of the file once it is loaded */ /* if you want to use latest file, put this into the loop */ epicsMutexMustLock( p_asynLink->imageBuffers.mutexLock ); result = loadImageFile( p_fileName, p_asynLink->imageBuffers.p_imageBuffer, IMAGE_BUFFER_SIZE, &imageWidth, &imageHeight, &imageSize ); epicsMutexUnlock( p_asynLink->imageBuffers.mutexLock ); if (result != asynSuccess) { fprintf(stderr, "failed to load the file %s\n", p_fileName ); return; } printf( "file %s loaded now start loop\n", p_fileName ); /* loop this is because background may be changed from ioc shell */ while (1) { sleep( 1 ); if (p_asynLink->ioResult.deviceAlarmCode) { p_asynLink->ioResult.deviceAlarmCode = 0; generateAsynDeviceAlarmInterrupt( p_asynLink ); } while (PGM_Profile( &localResult, &p_asynLink->ioConfig, p_asynLink->imageBuffers.p_imageBuffer, p_asynLink->imageBuffers.p_backgroundImageBuffer, imageWidth, imageHeight )) { if (p_asynLink->ioResult.deviceAlarmCode == 0) { p_asynLink->ioResult.deviceAlarmCode = 1; generateAsynDeviceAlarmInterrupt( p_asynLink ); } epicsMutexMustLock( p_asynLink->mutexLock ); p_asynLink->ioResult = localResult; epicsMutexUnlock( p_asynLink->mutexLock ); /* call all interrupt services */ generateAsynInt32Interrupt( p_asynLink ); generateAsynFloat64Interrupt( p_asynLink ); generateAsynInt32ArrayInterrupt( p_asynLink ); generateAsynFloat64ArrayInterrupt( p_asynLink ); usleep( 100000 ); } } /* forever */ }
//----------------------------------------------------------------------------- ImgChildWnd::ImgChildWnd(QString sFileName, QString sVarName, QWidget *parent) : QWidget(parent), m_pIplImage(0) { QImage img; bool br = false; br = loadImageFile(sFileName, img); if (br) { createContent(&img, parent); setWindowTitle(sVarName); } }
int runVm(int argc, char ** argv) { parseArguments(&argc, &argv); if(optImageFile == NULL) { printf("No image file specified.\n\n"); printUsage(); return 255; } if(!optInteractive && optScript == NULL && optScriptFile == NULL) { printf("No script specified.\n\n"); printUsage(); return 255; } allocateAll(); loadImageFile(optImageFile); passArguments(argc, argv); if(optInteractive) { repl(); } else { processScript(); } deallocateAll(); if(optPrintStatistics) { printf("\x1b[2m"); printf("\nMemory statistics:\n- objects allocated: %ld\n- size allocated: %.2lf MB\n", totalObjectsAllocated, (double) totalMemoryAllocated / 1000000 * sizeof(OP)); printf("\nGarbage collection statistics:\n- runs in new space: %d\n - avg new space reclaimed: %.2f %%\n - min new space reclaimed: %.2f %%\n - objects moved to old space: %ld\n- runs in old space: %d\n - avg old space reclaimed: %.2f %%\n - min old space reclaimed: %.2f %%\n", gcCount, gcCount ? (gcPercentSum / gcCount) : 0.0, gcCount ? gcPercentMin : 0.0, gcObjectsMovedToOld, gcOldCount, gcOldCount ? (gcOldPercentSum / gcOldCount) : 0.0, gcOldCount ? gcOldPercentMin : 0.0); printf("\x1b[0m"); } return 0; }
void meshLoadTexture(Mesh* mesh){ GLuint texID; glGenTextures(1, &texID); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texID); unsigned char* image_data; int x ,y; loadImageFile(TERRAIN_TEXTURE, true, &image_data, &x,&y); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data); free(image_data); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 4.0f); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); mesh->texture = texID; }
Mat getScaledImg(string src){ Mat source = loadImageFile(src); source = processImage(source); Mat eroded; source.copyTo(eroded); // Erosion kernal int erosion_type = MORPH_RECT; int erosion_size = 1; Mat kernal = getStructuringElement(erosion_type, Size( 2*erosion_size+1, 2*erosion_size+1), Point(erosion_size, erosion_size)); erode(eroded, eroded, kernal); return eroded; }
void MainWindow::createActions() { newAction=new QAction(tr("新建"),this); newAction->setIcon(QIcon("F:/QT4Project/knuth.jpg")); newAction->setShortcut(QKeySequence::New); connect(newAction,SIGNAL(triggered()),this,SLOT(newFile())); openAction=new QAction("打开",this); openAction->setIcon(QIcon("F:/QT4Project/8.jpg")); openAction->setShortcut(QKeySequence::Open); connect(openAction,SIGNAL(triggered()),widget,SLOT(loadImageFile())); saveAction=new QAction("保存",this); saveAction->setIcon(QIcon("F:/QT4Project/knuth.jpg")); saveAction->setShortcut(QKeySequence::Save); connect(saveAction,SIGNAL(triggered()),this,SLOT(saveFile())); for(int i=0;i<5;i++) { recentFileAction[i]=new QAction(this); recentFileAction[i]->setVisible(false); connect(recentFileAction[i],SIGNAL(triggered()),this,SLOT(openRecentFile())); } cutAction=new QAction("剪切",this); cutAction->setIcon(QIcon("F:/QT4Project/knuth.jpg:/")); //connect(cutAction,SIGNAL(triggered()),this,SLOT()) exitAction=new QAction("关闭",this); exitAction->setIcon(QIcon("F:/QT4Project/knuth.jpg")); exitAction->setShortcut(tr("Ctrl+W")); connect(exitAction,SIGNAL(triggered()),this,SLOT(close())); localCVAction=new QAction("LocalCV分割算法",this); localCVAction->setIcon(QIcon("F:/QT4Project/knuth.jpg:/")); connect(localCVAction,SIGNAL(triggered()),this,SLOT(localCV())); sradAction=new QAction("SRAD分割算法",this); connect(sradAction,SIGNAL(triggered()),this,SLOT(srad())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , showMessageTimout(3000) { createActions(); createMenus(); createToolBars(); createStatusBar(); createCentralWidget(); createDockWindows(); connect(pipelineWidget, SIGNAL(sourceCodeChanged(QString)), codeWidget, SLOT(setPlainText(QString))); connect(pipelineWidget, SIGNAL(outputPixmapChanged(QPixmap)), imageWidget, SLOT(updatePixmap(QPixmap))); setWindowTitle("Prototyping Toolkit for Image Processing"); loadImageFile(":/Images/lena.jpg"); resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5); }
void Gosu::loadImageFile(Gosu::Bitmap& bitmap, const std::wstring& filename) { Buffer buffer; loadFile(buffer, filename); loadImageFile(bitmap, buffer.frontReader()); }
Widget::Widget(QWidget* parent) :QWidget(parent) { //GroupBox styleGroupBox=new QGroupBox; styleGroupBox->setTitle(tr("图谱类型")); styleGroupBox->setStyleSheet (QString ("QGroupBox:title { color: blue; }")); bRadioButton=new QRadioButton; bRadioButton->setText(tr("B")); mRadioButton=new QRadioButton; mRadioButton->setText(tr("M")); dRadioButton=new QRadioButton; dRadioButton->setText(tr("D")); //图像框在左下角 //左下角上部 inputWordLabel=new QLabel; inputWordLabel->setText(tr("输入:X 输出: X")); describeMapComboBoxLabel=new QLabel; describeMapComboBoxLabel->setText(tr("图谱选择")); mapComboBox=new QComboBox; mapComboBox->addItem(tr("1")); mapComboBox->addItem(tr("2")); mapComboBox->addItem(tr("3")); imageGroupBox=new QGroupBox; imageGroupBox->setTitle("图像框"); imageGroupBox->setStyleSheet(QString("QGroupBox::title{color:blue;}")); origanlImageLabel=new QLabel; origanlImageLabel->setText("图一"); origanlImageLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); origanlImageLabel->setFrameStyle(2); secondImageLabel=new QLabel; secondImageLabel->setFrameStyle(2); secondImageLabel->setText("图二"); secondImageLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); thirdImageLabel=new QLabel; thirdImageLabel->setText("图三"); thirdImageLabel->setFrameStyle(2); thirdImageLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); fourthImageLabel=new QLabel; fourthImageLabel->setText("图四"); fourthImageLabel->setFrameStyle(2); fourthImageLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); //载入框在右边 loadButton=new QPushButton; loadButton->setText(tr("载入")); returnButton=new QPushButton; returnButton->setText(tr("返回")); //左上角内部布局 QHBoxLayout* leftTopLayout=new QHBoxLayout; leftTopLayout->addWidget(bRadioButton); leftTopLayout->addWidget(mRadioButton); leftTopLayout->addWidget(dRadioButton); styleGroupBox->setLayout(leftTopLayout); //左下角内部布局 QHBoxLayout* comboxLayout=new QHBoxLayout; comboxLayout->addWidget(describeMapComboBoxLabel); comboxLayout->addWidget(mapComboBox); QGridLayout* leftDownLayout=new QGridLayout; leftDownLayout->addWidget(inputWordLabel,0,0); leftDownLayout->addLayout(comboxLayout,0,1); leftDownLayout->addWidget(origanlImageLabel,1,0); leftDownLayout->addWidget(secondImageLabel,1,1); leftDownLayout->addWidget(thirdImageLabel,2,0); leftDownLayout->addWidget(fourthImageLabel,2,1); imageGroupBox->setLayout(leftDownLayout); //左边布局 QVBoxLayout* leftLayout=new QVBoxLayout; leftLayout->addWidget(styleGroupBox); leftLayout->addWidget(imageGroupBox); leftLayout->setStretchFactor(imageGroupBox,2); //右边布局. QVBoxLayout* rightLayout=new QVBoxLayout; rightLayout->addWidget(loadButton); rightLayout->addWidget(returnButton); rightLayout->addStretch(); //整体布局 QHBoxLayout* mainLayout=new QHBoxLayout; mainLayout->addLayout(leftLayout); mainLayout->addLayout(rightLayout); mainLayout->setStretchFactor(leftLayout,1); setWindowTitle(tr("超声乳腺系统")); setLayout(mainLayout); setMinimumSize(800,600);//设置窗口最小尺寸为800*600 resize(1024,768);//设置初始化尺寸 connect(loadButton,SIGNAL(clicked()),this,SLOT(loadImageFile())); }
int main(int argc, char** argv) { int i; imageInfoStruct imageInfo; bmpFileStruct sourceFile; unsigned char *imageArray; char path[BUFFER_SIZE]; char *label; int reps; clock_t time; clock_t allTime; flipFunc_pointer_t func; reps = DEF_REPS; strcpy(path, ""); printf("\n"); /* The parser of string with parameters. */ for (i=1; i<argc; i++) { if(argv[i][0] == '-') { switch (argv[i][1]) { case 'p': strncpy(path, &argv[i][2], BUFFER_SIZE); path[BUFFER_SIZE - 1] = '\0'; break; case 'r': reps = strtol(&argv[i][2], NULL, 0); if (reps == 0) showError("Wrong the number of repetitions."); break; default: printf("Wrong argument: %s\n", argv[i]); usage(); } } if(argv[i][0] == '/') { switch (argv[i][1]) { case '?': usage(); break; default: printf("Wrong argument: %s\n", argv[i]); usage(); } } } if (strlen(path) == 0) usage(); printf("Path to BMP file: %s\n", path); printf("Reps: %d\n",reps); imageInfo = loadImageFile(path, &sourceFile, &imageArray); printf("Resolution: %dx%d\n", imageInfo.width, imageInfo.height); func = &flipImageC; label = "Test 1 - using pure C"; doFlip(label, "_1_c_", reps, imageArray, imageInfo, sourceFile, path, func); func = &flipImageC_memcpy; label = "Test 2 - using C with memcpy function"; doFlip(label, "_2_c_memcpy_", reps, imageArray, imageInfo, sourceFile, path, func); func = &flipImageAsm; label = "Test 3 - using pure Asm"; doFlip(label, "_3_asm_", reps, imageArray, imageInfo, sourceFile, path, func); func = &flipImageMMX; label = "Test 4 - using asm with MMX"; doFlip(label, "_4_mmx_", reps, imageArray, imageInfo, sourceFile, path, func); free(imageArray); return 0; }
Gosu::Reader Gosu::loadFromPNG(Bitmap& bitmap, Reader reader) { loadImageFile(bitmap, reader); reader.setPosition(reader.resource().size()); return reader; }
std::vector<Gosu::Image> Gosu::loadTiles(Graphics& graphics, const std::wstring& filename, int tileWidth, int tileHeight, bool tileable) { Bitmap bmp; loadImageFile(bmp, filename); return loadTiles(graphics, bmp, tileWidth, tileHeight, tileable); }