size_t DeConv3DLayer::getSize() { CHECK_NE(inputLayers_.size(), 0UL); imgSizeW_.clear(); imgSizeH_.clear(); imgSizeD_.clear(); N_.clear(); NOut_.clear(); size_t layerSize = 0; for (size_t i = 0; i < inputLayers_.size(); ++i) { imgSizeW_.push_back( imageSize(outputW_[i], filterSize_[i], padding_[i], stride_[i], true)); imgSizeH_.push_back(imageSize( outputH_[i], filterSizeY_[i], paddingY_[i], strideY_[i], true)); imgSizeD_.push_back(imageSize( outputD_[i], filterSizeZ_[i], paddingZ_[i], strideZ_[i], true)); NOut_.push_back(imgSizeD_[i] * imgSizeH_[i] * imgSizeW_[i]); N_.push_back(outputD_[i] * outputH_[i] * outputW_[i]); CHECK(layerSize == 0 || N_[i] * size_t(numFilters_) == layerSize); layerSize += NOut_[i] * numFilters_; } getOutput().setFrameHeight(imgSizeH_[0]); getOutput().setFrameWidth(imgSizeW_[0]); getOutput().setFrameDepth(imgSizeD_[0]); return layerSize; }
int main(int argc, char *argv[]){ // storing arguments from the comman line int filter_width = parseWidth(argv); float filter_weight[filter_width*filter_width]; char *inputName = parseIn(argv); char *outputName = parseOut(argv); // parses the input weights from positional parameters parseWeight(filter_weight, argv, argc); // opening the files FILE *imageIn = fopen(inputName, "rb"); FILE *imageOut = fopen(outputName, "wb"); // initialize the before modification and after modification arrays unsigned char before[imageSize(imageIn)]; unsigned char after[imageSize(imageIn)]; // loading the raw data in to the before array loadBMP(imageIn, before); // apply the filter doFiltering(before, filter_weight, filter_width, after); // write to the new file fwrite(after, sizeof(unsigned char), imageSize(imageIn), imageOut); // closing the file. fclose(imageIn); fclose(imageOut); }
QPointF ImageView::image2view(const QPointF& q) const { QSize sz = size(); float z = m_zoom * m_resolution; return QPointF( (q.x() - imageSize().width() / 2) * z + m_origin.x() * z + sz.width() / 2, (q.y() - imageSize().height() / 2) * z + m_origin.y() * z + sz.height() / 2 ); }
QTransform ImageView::viewTransform(const QSizeF& sz, double zoom, const QPointF& origin) const { QTransform tr; tr.translate(sz.width()/2.0f, sz.height()/2.0f); tr.translate(origin.x() * zoom, origin.y() * zoom); tr.scale(zoom, zoom); tr.translate(-imageSize().width()/2.0f, -imageSize().height()/2.0f); return tr; }
QSizeF Image::scaleForSize(const QSizeF& s) const { QSizeF sz = s * scaleFactor(); return QSizeF( (sz.width() * 100.0)/ imageSize().width(), (sz.height() * 100.0)/ imageSize().height() ); }
QPointF ImageView::view2image(const QPointF& p) const { QSize sz = size(); float z = m_zoom * m_resolution; return QPointF( (p.x() - m_origin.x() * z - sz.width() / 2) / z + imageSize().width() / 2, (p.y() - m_origin.y() * z - sz.height() / 2) / z + imageSize().height() / 2 ); }
QSizeF Image::scaleForSize(const QSizeF& s) const { // QSizeF sz = s * (_sizeIsSpatium ? spatium() : MScore::DPMM); QSizeF sz = s * scaleFactor(); return QSizeF( (sz.width() * 100.0)/ imageSize().width(), (sz.height() * 100.0)/ imageSize().height() ); }
size_t ConvBaseLayer::calOutputSize() { auto clearAndReserve = [this](IntV* vec) { vec->clear(); vec->reserve(this->inputLayers_.size()); }; clearAndReserve(&imgSizeH_); clearAndReserve(&imgSizeW_); clearAndReserve(&outputH_); clearAndReserve(&outputW_); size_t layerSize = 0; auto setLayerSize = [&](IntV& inH, IntV& inW, IntV& outH, IntV& outW) { size_t filterSizeY; size_t filterSize; for (size_t i = 0; i < inputLayers_.size(); i++) { filterSizeY = (filterSizeY_[i] - 1) * dilationY_[i] + 1; filterSize = (filterSize_[i] - 1) * dilation_[i] + 1; inH.push_back(inputLayers_[i]->getOutput().getFrameHeight()); inW.push_back(inputLayers_[i]->getOutput().getFrameWidth()); const ConvConfig& conf = config_.inputs(i).conv_conf(); if (isDeconv_) { if (inH[i] == 0) inH[i] = conf.has_output_y() ? conf.output_y() : conf.output_x(); if (inW[i] == 0) inW[i] = conf.output_x(); outH.push_back(imageSize( inH[i], filterSizeY, paddingY_[i], strideY_[i], caffeMode_)); outW.push_back( imageSize(inW[i], filterSize, padding_[i], stride_[i], caffeMode_)); } else { if (inH[i] == 0) inH[i] = conf.has_img_size_y() ? conf.img_size_y() : conf.img_size(); if (inW[i] == 0) inW[i] = conf.img_size(); outH.push_back(outputSize( inH[i], filterSizeY, paddingY_[i], strideY_[i], caffeMode_)); outW.push_back(outputSize( inW[i], filterSize, padding_[i], stride_[i], caffeMode_)); } CHECK_EQ(outH[i], outH[0]); CHECK_EQ(outW[i], outW[0]); } getOutput().setFrameHeight(outH[0]); getOutput().setFrameWidth(outW[0]); layerSize = outH[0] * outW[0] * size_t(numFilters_); }; setLayerSize(imgSizeH_, imgSizeW_, outputH_, outputW_); return layerSize; }
glm::vec2 SpriteSheetRenderer::spriteSheetSize(SpriteSheetRenderer::SpriteSheetType type) { auto texture = m_spriteSheetTextures.find(type); glm::vec2 imageSize(float(texture->second.texture->width()), float(texture->second.texture->height())); return imageSize; }
void UserPicturesRequest::start() { QString size; switch( imageSize() ) { case SIZE_PAGE: size = "page"; break; case SIZE_LARGE: size = "large"; break; case SIZE_MEDIUM: size = "medium"; break; default: size = "small"; break; } XmlRpc xmlrpc; xmlrpc.setMethod( "getUserAvatars" ); xmlrpc << names(); xmlrpc << size; request( xmlrpc ); }
void ofxMapamok::calibrate(ofRectangle vp, vector<cv::Point2f>& imagePoints, vector<cv::Point3f>& objectPoints, int flags, float aov) { int n = imagePoints.size(); const static int minPoints = 6; if (n < minPoints) { calibrationReady = false; return; } vector<cv::Mat> rvecs, tvecs; vector<vector<cv::Point3f> > objectPointsCv; vector<vector<cv::Point2f> > imagePointsCv; cv::Point2f offset(vp.x, vp.y); if (offset == cv::Point2f(0, 0)) { imagePointsCv.push_back(imagePoints); } else { vector<cv::Point2f> offsetPoints; for (auto const& point : imagePoints) { offsetPoints.push_back(point - offset); } imagePointsCv.push_back(offsetPoints); } objectPointsCv.push_back(objectPoints); cv::Size2i imageSize(vp.width, vp.height); float f = imageSize.width * ofDegToRad(aov); // this might be wrong, but it's optimized out cv::Point2f c = cv::Point2f(imageSize) * (1. / 2); cv::Mat1d cameraMatrix = (cv::Mat1d(3, 3) << f, 0, c.x, 0, f, c.y, 0, 0, 1); cv::Mat distortionCoefficients; calibrateCamera(objectPointsCv, imagePointsCv, imageSize, cameraMatrix, distortionCoefficients, rvecs, tvecs, flags); setData(cameraMatrix, rvecs[0], tvecs[0], imageSize, distortionCoefficients); }
inline size_t CameraSet<T>::add( std::shared_ptr<cimg_library::CImg<uint8_t> > image, const std::string& name, const size_t cameraID ) { // assemble the pose Pose_d pose; pose.id = m_poseCount; pose.name = name; pose.image = image; // add the pose m_cameras[cameraID].poses.push_back( pose ); // get the image size Eigen::Vector2i imageSize( image->width(), image->height() ); // make sure the image sizes are the same if( m_cameras[cameraID].poses.size() == 1 ) { m_cameras[cameraID].id = cameraID; m_cameras[cameraID].imageSize = imageSize; } else { Eigen::Vector2i tmp = imageSize - m_cameras[cameraID].imageSize; if( (tmp(0) != 0) || (tmp(1) != 0) ) throw std::runtime_error( "CameraSet::addImage: pose has different image size than already stored poses." ); } // increment pose count and return id m_poseCount++; return pose.id; }
void StyleGeneratedImage::computeIntrinsicDimensions(const LayoutObject* layoutObject, FloatSize& intrinsicSize, FloatSize& intrinsicRatio) { // At a zoom level of 1 the image is guaranteed to have an integer size. LayoutSize size = imageSize(layoutObject, 1); ASSERT(size.fraction().isZero()); intrinsicSize = intrinsicRatio = FloatSize(size); }
void MainWindow::on_actionObject_Coordinates_Output_triggered() { QDir dir(workDirectory); //进入工作目录 if(!dir.exists() || workDirectory==""){ QMessageBox::warning(this,tr("Entering Workspace error!"),tr("No workspace has been opened!")); return; } QString image3DName=dir.absoluteFilePath(QString("NineImagesModel.md")); if(image3DName==""){ QMessageBox::warning(this,tr("Object coordinates output error!"),tr("No file \"NineImagesModel.md\" found!")); return; } IMAGE3D *image=new IMAGE3D[imageSize()]; if(!readSingleImage3D(image3DName.toStdString(),image)){ QMessageBox::warning(this,tr("Object coordinates output error!"),tr("Reading file \"NineImagesModel.md\" failed!")); return; } /* QString outFileName("ObjectCoors.txt"); if(!writeImage3DCoordinates(dir.absoluteFilePath(outFileName).toStdString(),image,imageWidth,imageHeight)){ QMessageBox::warning(this,tr("Object coordinates output error!"),tr("Writing file \"ObjectCoors.txt\" failed!")); return; } */ QString pcdFileName("ObjectCoors.pcd"); if(!writeToPCD(dir.absoluteFilePath(pcdFileName).toStdString(),image,imageWidth,imageHeight)){ QMessageBox::warning(this,tr("Object coordinates output error!"),tr("Writing file \"ObjectCoors.pcd\" failed!")); return; } delete [] image; QMessageBox::information(this,tr("Object coordinates output succeeds!"),tr("Object coordinates have been output to file \"ObjectCoors.txt\" and \"ObjectCoors.pcd\".")); }
void CubeMapTexture::image(const Coordinate coordinate, const Int level, Image2D& image) { const Vector2i size = imageSize(level); const std::size_t dataSize = image.dataSize(size); char* data = new char[dataSize]; (this->*Context::current()->state().texture->getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), dataSize, data); image.setData(image.format(), image.type(), size, data); }
LayoutSize CachedImage::imageSizeForRenderer(const RenderObject* renderer, float multiplier, SizeType sizeType) { ASSERT(!isPurgeable()); if (!m_image) return LayoutSize(); LayoutSize imageSize(m_image->size()); #if ENABLE(CSS_IMAGE_ORIENTATION) if (renderer && m_image->isBitmapImage()) { ImageOrientationDescription orientationDescription(renderer->shouldRespectImageOrientation(), renderer->style().imageOrientation()); if (orientationDescription.respectImageOrientation() == RespectImageOrientation) imageSize = LayoutSize(toBitmapImage(m_image.get())->sizeRespectingOrientation(orientationDescription)); } #else if (m_image->isBitmapImage() && (renderer && renderer->shouldRespectImageOrientation() == RespectImageOrientation)) #if !PLATFORM(IOS) imageSize = LayoutSize(toBitmapImage(m_image.get())->sizeRespectingOrientation()); #else { // On iOS, the image may have been subsampled to accommodate our size restrictions. However // we should tell the renderer what the original size was. imageSize = LayoutSize(toBitmapImage(m_image.get())->originalSizeRespectingOrientation()); } else if (m_image->isBitmapImage())
void LayoutListMarker::layout() { ASSERT(needsLayout()); LayoutAnalyzer::Scope analyzer(*this); if (isImage()) { updateMarginsAndContent(); LayoutSize imageSize(imageBulletSize()); setWidth(imageSize.width()); setHeight(imageSize.height()); } else { const SimpleFontData* fontData = style()->font().primaryFont(); DCHECK(fontData); setLogicalWidth(minPreferredLogicalWidth()); setLogicalHeight( LayoutUnit(fontData ? fontData->getFontMetrics().height() : 0)); } setMarginStart(LayoutUnit()); setMarginEnd(LayoutUnit()); Length startMargin = style()->marginStart(); Length endMargin = style()->marginEnd(); if (startMargin.isFixed()) setMarginStart(LayoutUnit(startMargin.value())); if (endMargin.isFixed()) setMarginEnd(LayoutUnit(endMargin.value())); clearNeedsLayout(); }
void Image::layout() { qreal f = _sizeIsSpatium ? spatium() : MScore::DPMM; // if autoscale && inside a box, scale to box relevant size if (autoScale() && parent() && ((parent()->type() == HBOX || parent()->type() == VBOX))) { if (_lockAspectRatio) { QSizeF size(imageSize()); qreal ratio = size.width() / size.height(); qreal w = parent()->width(); qreal h = parent()->height(); if ((w / h) < ratio) { _size.setWidth(w / f); _size.setHeight((w / ratio) / f); } else { _size.setHeight(h / f); _size.setWidth(h * ratio / f); } } else _size = parent()->bbox().size() / f; } // in any case, adjust position relative to parent adjustReadPos(); setbbox(QRectF(0.0, 0.0, _size.width() * f, _size.height() * f)); }
//Decode all the .gnt files in the file list. void QxMainWindow::decodeAll() { if (m_FileList.isEmpty()) { QString strTitle("No selected files"); QString strMessage("No files selected yet. Please press \"Open\" to select files first."); QMessageBox::information(this, strTitle, strMessage, QMessageBox::Ok); return; } // If user clicks "Cancel" button when selection decoding options, do not decode files. QxDecodeOptionDlg dlg(m_FileList, this); if (dlg.exec() != QxDecodeOptionDlg::Accepted) { return; } // get selected application, image size, as well as image format unsigned uImageSize = dlg.imageSize(); cv::Size imageSize(uImageSize, uImageSize); QString strImageFormat = dlg.imageFormat(); QString strDestinationPath = dlg.filePath(); QxDecodeOptionDlg::ApplicationType appType = dlg.application(); //If files are successfully decode, show a messagebox to inform user. if (decodeFiles(m_FileList, strDestinationPath, strImageFormat, imageSize, appType)) { QString strMessage("Files successfully decoded."); QMessageBox::information(this, "Result", strMessage, QMessageBox::Ok); } }
LayoutSize CachedImage::imageSizeForRenderer(const RenderObject* renderer, float multiplier, SizeType sizeType) { if (!m_image) return LayoutSize(); LayoutSize imageSize(m_image->size()); #if ENABLE(CSS_IMAGE_ORIENTATION) if (renderer && is<BitmapImage>(*m_image)) { ImageOrientationDescription orientationDescription(renderer->shouldRespectImageOrientation(), renderer->style().imageOrientation()); if (orientationDescription.respectImageOrientation() == RespectImageOrientation) imageSize = LayoutSize(downcast<BitmapImage>(*m_image).sizeRespectingOrientation(orientationDescription)); } #else if (is<BitmapImage>(*m_image) && (renderer && renderer->shouldRespectImageOrientation() == RespectImageOrientation)) imageSize = LayoutSize(downcast<BitmapImage>(*m_image).sizeRespectingOrientation()); #endif // ENABLE(CSS_IMAGE_ORIENTATION) else if (is<SVGImage>(*m_image) && sizeType == UsedSize) { imageSize = LayoutSize(m_svgImageCache->imageSizeForRenderer(renderer)); } if (multiplier == 1.0f) return imageSize; // Don't let images that have a width/height >= 1 shrink below 1 when zoomed. float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier; LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0); imageSize.scale(widthScale, heightScale); imageSize.clampToMinimumSize(minimumSize); ASSERT(multiplier != 1.0f || (imageSize.width().fraction() == 0.0f && imageSize.height().fraction() == 0.0f)); return imageSize; }
/* static */ void nsSVGIntegrationUtils::DrawPaintServer(nsRenderingContext* aRenderingContext, nsIFrame* aTarget, nsIFrame* aPaintServer, gfxPattern::GraphicsFilter aFilter, const nsRect& aDest, const nsRect& aFill, const nsPoint& aAnchor, const nsRect& aDirty, const nsSize& aPaintServerSize) { if (aDest.IsEmpty() || aFill.IsEmpty()) return; PRInt32 appUnitsPerDevPixel = aTarget->PresContext()->AppUnitsPerDevPixel(); nsRect destSize = aDest - aDest.TopLeft(); nsIntSize roundedOut = destSize.ToOutsidePixels(appUnitsPerDevPixel).Size(); gfxIntSize imageSize(roundedOut.width, roundedOut.height); nsRefPtr<gfxDrawable> drawable = DrawableFromPaintServer(aPaintServer, aTarget, aPaintServerSize, imageSize); if (drawable) { nsLayoutUtils::DrawPixelSnapped(aRenderingContext, drawable, aFilter, aDest, aFill, aAnchor, aDirty); } }
void LayoutListMarker::computePreferredLogicalWidths() { ASSERT(preferredLogicalWidthsDirty()); updateContent(); if (isImage()) { LayoutSize imageSize(imageBulletSize()); m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = style()->isHorizontalWritingMode() ? imageSize.width() : imageSize.height(); clearPreferredLogicalWidthsDirty(); updateMargins(); return; } const Font& font = style()->font(); LayoutUnit logicalWidth = 0; switch (listStyleCategory()) { case ListStyleCategory::None: break; case ListStyleCategory::Symbol: logicalWidth = (font.fontMetrics().ascent() * 2 / 3 + 1) / 2 + 2; break; case ListStyleCategory::Language: logicalWidth = getWidthOfTextWithSuffix(); break; } m_minPreferredLogicalWidth = logicalWidth; m_maxPreferredLogicalWidth = logicalWidth; clearPreferredLogicalWidthsDirty(); updateMargins(); }
void LayoutListMarker::layout() { ASSERT(needsLayout()); LayoutAnalyzer::Scope analyzer(*this); if (isImage()) { updateMarginsAndContent(); LayoutSize imageSize(imageBulletSize()); setWidth(imageSize.width()); setHeight(imageSize.height()); } else { setLogicalWidth(minPreferredLogicalWidth()); setLogicalHeight(style()->fontMetrics().height()); } setMarginStart(0); setMarginEnd(0); Length startMargin = style()->marginStart(); Length endMargin = style()->marginEnd(); if (startMargin.isFixed()) setMarginStart(startMargin.value()); if (endMargin.isFixed()) setMarginEnd(endMargin.value()); clearNeedsLayout(); }
TexturePtr TextureManager::loadTexture(std::stringstream& file) { TexturePtr texture; apng_data apng; if(load_apng(file, &apng) == 0) { Size imageSize(apng.width, apng.height); if(apng.num_frames > 1) { // animated texture std::vector<ImagePtr> frames; std::vector<int> framesDelay; for(uint i=0;i<apng.num_frames;++i) { uchar *frameData = apng.pdata + ((apng.first_frame+i) * imageSize.area() * apng.bpp); int frameDelay = apng.frames_delay[i]; framesDelay.push_back(frameDelay); frames.push_back(ImagePtr(new Image(imageSize, apng.bpp, frameData))); } AnimatedTexturePtr animatedTexture = new AnimatedTexture(imageSize, frames, framesDelay); m_animatedTextures.push_back(animatedTexture); texture = animatedTexture; } else { ImagePtr image = ImagePtr(new Image(imageSize, apng.bpp, apng.pdata)); texture = TexturePtr(new Texture(image)); } free_apng(&apng); } return texture; }
//-------------------------------------------------------------- void ofApp::setup() { #ifdef TARGET_OPENGLES // While this will will work on normal OpenGL as well, it is // required for OpenGL ES because ARB textures are not supported. // If this IS set, then we conditionally normalize our // texture coordinates below. ofEnableNormalizedTexCoords(); #endif img.load("linzer.png"); // OF_PRIMITIVE_TRIANGLES means every three vertices create a triangle mesh.setMode(OF_PRIMITIVE_TRIANGLES); int skip = 10; // this controls the resolution of the mesh int width = img.getWidth(); int height = img.getHeight(); ofVec2f imageSize(width,height); ofVec3f zero(0, 0, 0); for(int y = 0; y < height - skip; y += skip) { for(int x = 0; x < width - skip; x += skip) { /* To construct a mesh, we have to build a collection of quads made up of the current pixel, the one to the right, to the bottom right, and beneath. These are called nw, ne, se and sw. To get the texture coords we need to use the actual image indices. */ ofVec3f nw = getVertexFromImg(img, x, y); ofVec3f ne = getVertexFromImg(img, x + skip, y); ofVec3f sw = getVertexFromImg(img, x, y + skip); ofVec3f se = getVertexFromImg(img, x + skip, y + skip); ofVec2f nwi(x, y); ofVec2f nei(x + skip, y); ofVec2f swi(x, y + skip); ofVec2f sei(x + skip, y + skip); // ignore any zero-data (where there is no depth info) if(nw != zero && ne != zero && sw != zero && se != zero) { addFace(mesh, nw, ne, se, sw); // Normalize our texture coordinates if normalized // texture coordinates are currently enabled. if(ofGetUsingNormalizedTexCoords()) { nwi /= imageSize; nei /= imageSize; sei /= imageSize; swi /= imageSize; } addTexCoords(mesh, nwi, nei, sei, swi); } } } vboMesh = mesh; }
void StyleGeneratedImage::computeIntrinsicDimensions(const RenderObject* renderer, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) { // At a zoom level of 1 the image is guaranteed to have an integer size. IntSize size = flooredIntSize(imageSize(renderer, 1)); intrinsicWidth = Length(size.width(), Fixed); intrinsicHeight = Length(size.height(), Fixed); intrinsicRatio = size; }
void ImageEntry::updateEntry() { qreal oldHeight = height(); if (m_imagePath.isEmpty()) { m_textItem->setPlainText(i18n("Right click here to insert image")); m_textItem->setVisible(true); if (m_imageItem) m_imageItem->setVisible(false); } else { if (!m_imageItem) m_imageItem = new WorksheetImageItem(this); if (m_imagePath.toLower().endsWith(QLatin1String(".eps"))) { m_imageItem->setEps(QUrl::fromLocalFile(m_imagePath)); } else { QImage img(m_imagePath); m_imageItem->setImage(img); } if (!m_imageItem->imageIsValid()) { const QString msg = i18n("Cannot load image %1").arg(m_imagePath); m_textItem->setPlainText(msg); m_textItem->setVisible(true); m_imageItem->setVisible(false); } else { QSizeF size; if (worksheet()->isPrinting() && ! m_useDisplaySizeForPrinting) size = imageSize(m_printSize); else size = imageSize(m_displaySize); // Hack: Eps images need to be scaled if (m_imagePath.toLower().endsWith(QLatin1String(".eps"))) size /= worksheet()->epsRenderer()->scale(); m_imageItem->setSize(size); qDebug() << size; m_textItem->setVisible(false); m_imageItem->setVisible(true); } } qDebug() << oldHeight << height(); if (oldHeight != height()) recalculateSize(); }
QSizeF Image::sizeForScale(const QSizeF& scale) const { QSizeF s = scale / 100.0; // qreal sz = _sizeIsSpatium ? spatium() : MScore::DPMM; // QSizeF oSize = imageSize() / sz; QSizeF oSize = imageSize() / scaleFactor(); return QSizeF(s.width() * oSize.width(), s.height() * oSize.height()); }
void MainWindow::on_actionRestructed_Model_Show_triggered() { QDir dir(workDirectory); //进入工作目录 if(!dir.exists()){ QMessageBox::warning(this,tr("Entering Workspace error!"),tr("No workspace has been opened!")); return; } QString image3DName=dir.absoluteFilePath(QString("NineImagesModel.md")); if(image3DName==""){ QMessageBox::warning(this,tr("Object coordinates output error!"),tr("No file \"NineImagesModel.md\" found!")); return; } IMAGE3D *image=new IMAGE3D[imageSize()]; if(!readSingleImage3D(image3DName.toStdString(),image)){ QMessageBox::warning(this,tr("Object coordinates output error!"),tr("Reading file \"NineImagesModel.md\" failed!")); return; } /* QString nameCoorNorm=dir.absoluteFilePath(QString("ObjectCoorsNormals.pcd")); if(nameCoorNorm==""){ QMessageBox::warning(this,tr("Object coordinates and normals reading error!"),tr("No file \"ObjectCoorsNormals.pcd\" found!")); return; } if(!readFromPCD(image,imageWidth,imageHeight,nameCoorNorm.toStdString())){ QMessageBox::warning(this,tr("Object coordinates and normals reading error!"),tr("Reading file \"ObjectCoorsNormals.pcd\" failed!")); return; } QString outFileName("ObjectCoorsNormals.txt"); if(!writeImage3DCoordinates(dir.absoluteFilePath(outFileName).toStdString(),image,imageWidth,imageHeight)){ QMessageBox::warning(this,tr("Object coordinates output error!"),tr("Writing file \"ObjectCoorsNormals.txt\" failed!")); return; } */ /* Point TT(5.9049,0.1402,8.3733); double m[3][3]={{0.8636,0.0067,0.5042},{-0.0082,0.999999,0.0008},{-0.5042,-0.0048,0.8636}}; Mat3 RR(m); for(unsigned int i=0;i<imageSize();i++){ image[i].coor=RR*image[i].coor+TT; } */ if(modelShow==0){ modelShow=new ModelShow(imageWidth,imageHeight); } modelShow->setImage(image); QDesktopWidget* desktopWidget = QApplication::desktop(); //获取屏幕可用大小 QRect deskRect = desktopWidget->availableGeometry(); //获取屏幕实际大小 //QRect screenRect = desktopWidget->screenGeometry(); int availX=modelShow->frameGeometry().width()-modelShow->geometry().width(); int availY=modelShow->frameGeometry().height()-modelShow->geometry().height(); modelShow->setGeometry(availX-availX/2,availY-availX/2,deskRect.width()-availX,deskRect.height()-availY); //modelShow->setFixedSize(deskRect.width()-availX,deskRect.height()-availY); modelShow->drawModel(); modelShow->show(); delete [] image; }
void Image::layout() { setPos(0.0, 0.0); if (imageType == ImageType::SVG && !svgDoc) { if (_storeItem) { svgDoc = new QSvgRenderer(_storeItem->buffer()); if (svgDoc->isValid()) { if (_size.isNull()) { _size = svgDoc->defaultSize(); if (_sizeIsSpatium) _size /= 10.0; // by convention } } } } else if (imageType == ImageType::RASTER && !rasterDoc) { if (_storeItem) { rasterDoc = new QImage; rasterDoc->loadFromData(_storeItem->buffer()); if (!rasterDoc->isNull()) { if (_size.isNull()) { _size = rasterDoc->size() * 0.4; if (_sizeIsSpatium) _size /= spatium(); else _size /= MScore::DPMM; } _dirty = true; } } } qreal f = _sizeIsSpatium ? spatium() : MScore::DPMM; // if autoscale && inside a box, scale to box relevant size if (autoScale() && parent() && ((parent()->type() == Element::Type::HBOX || parent()->type() == Element::Type::VBOX))) { if (_lockAspectRatio) { QSizeF size(imageSize()); qreal ratio = size.width() / size.height(); qreal w = parent()->width(); qreal h = parent()->height(); if ((w / h) < ratio) { _size.setWidth(w / f); _size.setHeight((w / ratio) / f); } else { _size.setHeight(h / f); _size.setWidth(h * ratio / f); } } else _size = parent()->bbox().size() / f; } // in any case, adjust position relative to parent adjustReadPos(); bbox().setRect(0.0, 0.0, _size.width() * f, _size.height() * f); }