Пример #1
0
void    amyCubeLing::AdjustImageDirectionFromView(QImage& img)
{
	if(this->GetInputView()==amyUtil::AXIAL)
	{
		if(this->GetView()==amyUtil::CORONAL)
		{
			img=img.mirrored();
		}
		else if(this->GetView()==amyUtil::SAGITTAL)
		{
			img=img.mirrored();
		}
	}
	if(this->GetInputView()==amyUtil::CORONAL)
	{
		if(this->GetView()==amyUtil::AXIAL)
		{
			img=img.mirrored();
		}
		else if(this->GetView()==amyUtil::SAGITTAL)
		{
			img=img.mirrored(1,0);
		}
	}
}
void Scene::genFrames()
{
    QPixmap pixmap = QPixmap( QString( ":Textures/pla1.bmp" ) );
    const unsigned int step = pixmap.width() / 4;
    QPixmap copyPixmap;
    for ( unsigned int i = 0; i < 4; ++i ) {
        copyPixmap = pixmap.copy( i * step, 0, step, step );
        framesToRight.push_back( copyPixmap );
    }

    for( unsigned int i = 0; i < framesToRight.size(); ++i ) {
        QImage image = framesToRight[i].toImage();
        framesToLeft.push_back( QPixmap::fromImage( image.mirrored( true, false ) ) );
    }

    for( unsigned int i = 0; i < framesToRight.size(); ++i ) {
        QPixmap rotatedPixmap( framesToRight[i] );
        QMatrix rm;
        rm.rotate( 90 );
        framesToDown.push_back( rotatedPixmap.transformed( rm ) );
    }

    for( unsigned int i = 0; i < framesToDown.size(); ++i ) {
        QImage image = framesToDown[i].toImage();
        framesToUp.push_back( QPixmap::fromImage( image.mirrored( false, true ) ) );
    }
}
Пример #3
0
static QImage rotate(const QImage &src,
                     NemoImageMetadata::Orientation orientation)
{
    QTransform trans;
    QImage dst, tmp;

    /* For square images 90-degree rotations of the pixel could be
       done in-place, and flips could be done in-place for any image
       instead of using the QImage routines which make copies of the
       data. */

    switch (orientation) {
        case NemoImageMetadata::TopRight:
            /* horizontal flip */
            dst = src.mirrored(true, false);
            break;
        case NemoImageMetadata::BottomRight:
            /* horizontal flip, vertical flip */
            dst = src.mirrored(true, true);
            break;
        case NemoImageMetadata::BottomLeft:
            /* vertical flip */
            dst = src.mirrored(false, true);
            break;
        case NemoImageMetadata::LeftTop:
            /* rotate 90 deg clockwise and flip horizontally */
            trans.rotate(90.0);
            tmp = src.transformed(trans);
            dst = tmp.mirrored(true, false);
            break;
        case NemoImageMetadata::RightTop:
            /* rotate 90 deg anticlockwise */
            trans.rotate(90.0);
            dst = src.transformed(trans);
            break;
        case NemoImageMetadata::RightBottom:
            /* rotate 90 deg anticlockwise and flip horizontally */
            trans.rotate(-90.0);
            tmp = src.transformed(trans);
            dst = tmp.mirrored(true, false);
            break;
        case NemoImageMetadata::LeftBottom:
            /* rotate 90 deg clockwise */
            trans.rotate(-90.0);
            dst = src.transformed(trans);
            break;
        default:
            dst = src;
            break;
    }

    return dst;
}
Пример #4
0
void MainWidget::initTextures()
{

    QRgb *row;
    QImage earth;

    qDebug() << "loading earthalpha.png";
    bool ok = earth.load("../earth10-master/earthalpha.png");

    if(ok)
    {
        textureearth = new QOpenGLTexture(QOpenGLTexture::Target::Target2D );
        textureearth->create();
        textureearth->setFormat(QOpenGLTexture::RGBA8_UNorm);
        textureearth->setData(earth.mirrored(true,false));
        textureearth->setMinificationFilter(QOpenGLTexture::Linear);
        textureearth->setMagnificationFilter(QOpenGLTexture::Linear);
        textureearth->setWrapMode(QOpenGLTexture::ClampToEdge);
        int texId = textureearth->textureId();
        qDebug() << QString("ID texture Earth = %1").arg(texId);
    }
    else
    {
        qDebug() << "error loading earthalpha";
        return;
    }

    qDebug() << "loading normal map";
    ok = earth.load("../earth10-master/EarthNormal.png");

    if(ok)
    {
        texturenormal = new QOpenGLTexture(QOpenGLTexture::Target::Target2D );
        texturenormal->create();
        texturenormal->setFormat(QOpenGLTexture::RGBA8_UNorm);
        texturenormal->setData(earth.mirrored(true,false));
        texturenormal->setMinificationFilter(QOpenGLTexture::Linear);
        texturenormal->setMagnificationFilter(QOpenGLTexture::Linear);
        texturenormal->setWrapMode(QOpenGLTexture::ClampToEdge);
        int texId = texturenormal->textureId();
        qDebug() << QString("ID texture Normal map = %1").arg(texId);
    }
    else
    {
        qDebug() << "error loading normal map";
        return;
    }

}
Пример #5
0
    // do not call this directly
    bool
    init( QString fname )
    {
        QImage qimg;
        m_valid = qimg.load( fname );
        if ( ! m_valid ) {
            return false;
        }
        qimg = qimg.mirrored( false, true );
        if ( qimg.format() != QImage::Format_ARGB32_Premultiplied ) {
            qimg = qimg.convertToFormat( QImage::Format_ARGB32_Premultiplied );
        }

        // prepare dimensions
        m_dims[0] = qimg.width();
        m_dims[1] = qimg.height();

        // prepare metadata
        m_mdi = std::make_shared < QImageMDI > ( shared_from_this() );

        // extract the actual pixels and store it in our own data buffer (only one byte
        // per pixel, gray equivalent to be precise)
        m_data = std::make_shared < std::vector < unsigned char > > ( m_dims[0] * m_dims[1] );
        unsigned int * src = (unsigned int *) qimg.bits();
        int count = qimg.width() * qimg.height();
        unsigned char * dst = & m_data-> at( 0 );
        for ( int i = 0 ; i < count ; ++i ) {
            * dst = qGray( * src );
            src++;
            dst++;
        }
        return true;
    } // init
Пример #6
0
QImage DesignerSupport::renderImageForItem(QQuickItem *referencedItem, const QRectF &boundingRect, const QSize &imageSize)
{
    if (referencedItem == 0 || referencedItem->parentItem() == 0) {
        qDebug() << __FILE__ << __LINE__ << "Warning: Item can be rendered.";
        return QImage();
    }

    QSGLayer *renderTexture = m_itemTextureHash.value(referencedItem);

    Q_ASSERT(renderTexture);
    if (renderTexture == 0)
         return QImage();
    renderTexture->setRect(boundingRect);
    renderTexture->setSize(imageSize);
    renderTexture->setItem(QQuickItemPrivate::get(referencedItem)->rootNode());
    renderTexture->markDirtyTexture();
    renderTexture->updateTexture();

    QImage renderImage = renderTexture->toImage();
    renderImage = renderImage.mirrored(false, true);

    if (renderImage.size().isEmpty())
        qDebug() << __FILE__ << __LINE__ << "Warning: Image is empty.";

    return renderImage;
}
void MyWindow::PrepareCubeMap(GLenum TextureUnit, const QString& BaseFileName, bool flip)
{
    glActiveTexture(TextureUnit);

    glGenTextures(1, &SkyBoxTexId);
    glBindTexture(GL_TEXTURE_CUBE_MAP, SkyBoxTexId);

    const char * suffixes[] = { "posx", "negx", "posy", "negy", "posz", "negz" };
    GLuint targets[] = {
        GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
        GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
    };

    // Allocate immutable storage for the cube map texture
    mFuncs->glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 256, 256);

    // Load each cube-map face
    QImage TexImg;
    for(int i=0; i<6; i++) {
        QString TexName = QString(BaseFileName) + "_" + suffixes[i] + ".png";
        if (!TexImg.load(TexName)) qDebug() << "Erreur chargement texture " << TexName;
        if (flip==true) TexImg=TexImg.mirrored();

        mFuncs->glTexSubImage2D(targets[i], 0, 0, 0, TexImg.width(), TexImg.height(), GL_BGRA, GL_UNSIGNED_BYTE, TexImg.bits());
    }

    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
}
Пример #8
0
JDTrees::JDTrees(QVector<JDTree> trees,QString fileName)
{
    isRoot = false;
    this->trees = trees;

    QImage img;
    img.load(appPath+fileName);
    //OpenGL expects image data to start at bottom left
    img = img.mirrored(false);
    glGenTextures(1, &texID);
    glBindTexture(GL_TEXTURE_2D, texID);

    //Compulsory OpenGL parameters
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    //Copy image pixels to GPU
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    //QImage RGBA is BGRA
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
                 img.width(), img.height(), 0,
                 GL_BGRA, GL_UNSIGNED_BYTE, img.bits());
    jdUtility::CheckGL("glTexImage2D");

    //qDebug()<<"Loaded tree image";
}
Пример #9
0
bool DkBatchTransform::compute(QImage& img, QStringList& logStrings) const {

    if (!isActive()) {
        logStrings.append(QObject::tr("%1 inactive -> skipping").arg(name()));
        return true;
    }

    QImage tmpImg;

    if (mAngle != 0) {
        QTransform rotationMatrix;
        rotationMatrix.rotate((double)mAngle);
        tmpImg = img.transformed(rotationMatrix);
    }
    else
        tmpImg = img;

    tmpImg = tmpImg.mirrored(mHorizontalFlip, mVerticalFlip);

    if (!tmpImg.isNull()) {
        img = tmpImg;
        logStrings.append(QObject::tr("%1 image transformed.").arg(name()));
    }
    else {
        logStrings.append(QObject::tr("%1 error, could not transform image.").arg(name()));
        return false;
    }

    return true;
}
void FlipHorAction::perform(ImageArea *area, bool prev)
{
	area->applySelection();

	QImage *img;
	QPainter *paint;

	if (prev)
	{
		img = area->preview;
		paint = new QPainter(img);
	}
	else
	{
		img = area->image;
		paint = area->painter;
	}

	QImage newImg = img->mirrored(true, false);

	//Swap the two images
	paint->end();
	img->swap(newImg);
	paint->begin(img);

	if (prev)
	{
		delete paint;
	}
}
Пример #11
0
void ccMaterial::setTexture(QImage image, QString absoluteFilename/*=QString()*/, bool mirrorImage/*=true*/)
{
	ccLog::PrintDebug(QString("[ccMaterial::setTexture] absoluteFilename = '%1' / size = %2 x %3").arg(absoluteFilename).arg(image.width()).arg(image.height()));

	if (absoluteFilename.isEmpty())
	{
		//if the user hasn't provided any filename, we generate a fake one
		absoluteFilename = QString("tex_%1.jpg").arg(m_uniqueID);
		assert(!s_materialDB.hasTexture(absoluteFilename));
	}
	else
	{
		//if the texture has already been loaded
		if (s_materialDB.hasTexture(absoluteFilename))
		{
			//check that the size is compatible at least
			if (s_materialDB.getTexture(absoluteFilename).size() != image.size())
			{
				assert(false); //shouldn't happen anymore
				ccLog::Warning(QString("[ccMaterial] A texture with the same name (%1) but with a different size has already been loaded!").arg(absoluteFilename));
			}
			m_textureFilename = absoluteFilename;
			s_materialDB.increaseTextureCounter(absoluteFilename);
			return;
		}
	}

	m_textureFilename = absoluteFilename;

	//insert image into DB if necessary
	s_materialDB.addTexture(m_textureFilename, mirrorImage ? image.mirrored() : image);
}
Пример #12
0
void QvkWebcamController::setNewImage( QImage image )
{
  if ( mirrored == true )
    image = image.mirrored ( true, false );

  if (radioButtonLeftMiddle->isChecked() == true )
      rotateDial->setValue( 90 );
  
  if ( radioButtonTopMiddle->isChecked() == true )
    rotateDial->setValue( 180 );

  if ( radioButtonRightMiddle->isChecked() == true )
    rotateDial->setValue( 270 );
  
  if ( radioButtonBottomMiddle->isChecked() == true )
    rotateDial->setValue( 360 );


  QTransform transform;
  transform.rotate( rotateDial->value() );
  QImage transformedImage = image.transformed( transform );

  // Passt Bild beim resizen des Fensters an
  transformedImage = transformedImage.scaled( webcamWindow->webcamLabel->width(), webcamWindow->webcamLabel->height(), Qt::KeepAspectRatio, Qt::FastTransformation);
  webcamWindow->webcamLabel->setPixmap( QPixmap::fromImage( transformedImage, Qt::AutoColor) );
}
void ApplicationUIBase::mirror_photo(QString file_path)
{
    QImage image = QImage(file_path);
    image = image.mirrored(true, false);
    image.save(file_path, "JPG");

    qDebug() << "MIRRORED: " + file_path;
}
Пример #14
0
QImage Tags::normalize(const QImage &image)
{
  QImage result = image;

#ifdef EXIF
  switch (value(EXIF_TAG_ORIENTATION).second.value.toInt())
  {
    case 1:
      break;

    case 2:
      result = result.mirrored(true,false);
      break;

    case 3:
      result = result.mirrored(true,true);
      break;

    case 4:
      result = result.mirrored(false,true);
      break;

    case 5:
      result = result.transformed(QTransform().rotate(90),Qt::SmoothTransformation).mirrored(true,false);
      break;

    case 6:
      result = result.transformed(QTransform().rotate(90),Qt::SmoothTransformation);
      break;

    case 7:
      result = result.transformed(QTransform().rotate(270),Qt::SmoothTransformation).mirrored(true,false);
      break;

    case 8:
      result = result.transformed(QTransform().rotate(270),Qt::SmoothTransformation);
      break;

    default:
      break;
  }
#endif

  return result;
}
Пример #15
0
QImage Sprite::getImageMirrored(int sequence) {
    if (sequence <= anzahl) {
        QRect rect(y * (sequence), 0, y, y);
        QImage returnImage = bild.copy(rect);
        return returnImage.mirrored(true, false);
    } else {
        return bild.mirrored(true, false);
    }
}
Пример #16
0
//----------------------------------------------------------------------------------------------------------------------
// Qt Image loading routines
//----------------------------------------------------------------------------------------------------------------------
bool Image::load( const std::string &_fName  ) noexcept
{
#ifdef IMAGE_DEBUG_ON
  std::cerr<<"loading with QImage"<<std::endl;
#endif
  QImage image;
  bool loaded=image.load(_fName.c_str());
  if(loaded ==false)
  {
    std::cerr<<"error loading image "<<_fName.c_str()<<"\n";
  }
  if(loaded == true)
  {
    image=image.mirrored();
    m_width=static_cast<GLuint> (image.width());
    m_height=static_cast<GLuint> (image.height());
    m_hasAlpha=image.hasAlphaChannel();
    if(m_hasAlpha == true)
    {
      m_channels=4;
      m_format = GL_RGBA;
    }
    else
    {
      m_channels=3;
      m_format = GL_RGB;
    }

    m_data.reset(new unsigned char[ m_width*m_height*m_channels]);
    unsigned int index=0;
    QRgb colour;
    for(unsigned int y=0; y<m_height; ++y)
    {
      for(unsigned int x=0; x<m_width; ++x)
      {
        colour=image.pixel(x,y);

        m_data[index++]=static_cast<unsigned char> (qRed(colour));
        m_data[index++]=static_cast<unsigned char> (qGreen(colour));
        m_data[index++]=static_cast<unsigned char> (qBlue(colour));
        if(m_hasAlpha)
        {
          m_data[index++]=static_cast<unsigned char> (qAlpha(colour));
        }
      }
    }
#ifdef IMAGE_DEBUG_ON
  std::cerr<<"size "<<m_width<<" "<<m_height<<std::endl;
  std::cerr<<"channels "<<m_channels<<std::endl;
#endif

   return true;

  }

  else return false;
}
Пример #17
0
TRaster32P rasterFromQImage(
    QImage image, bool premultiply,
    bool mirror)  // no need of const& - Qt uses implicit sharing...
{
  QImage copyImage = mirror ? image.mirrored() : image;
  TRaster32P ras(image.width(), image.height(), image.width(),
                 (TPixelRGBM32 *)copyImage.bits(), false);
  if (premultiply) TRop::premultiply(ras);
  return ras->clone();
}
Пример #18
0
StillImage::StillImage(const VideoInfo &backgroundVideoInfo, const QImage &image,
                       IScriptEnvironment* env)
    : m_videoInfo(backgroundVideoInfo)
{
    m_videoInfo.pixel_type =
            (image.format() == QImage::Format_ARGB32
                || image.format() == QImage::Format_ARGB32_Premultiplied) ?
                    VideoInfo::CS_BGR32 : VideoInfo::CS_BGR24;
    m_frame = env->NewVideoFrame(m_videoInfo);
    unsigned char* frameBits = m_frame->GetWritePtr();
    env->BitBlt(frameBits, m_frame->GetPitch(), image.mirrored(false, true).bits(), m_frame->GetPitch(), image.bytesPerLine(), image.height());
}
Пример #19
0
GLuint AnimeGLWidget::bindTexture(QImage &image)
{
    makeCurrent();
    QOpenGLTexture *pTexture = new QOpenGLTexture(image.mirrored(), QOpenGLTexture::DontGenerateMipMaps);
    if (m_pSetting->getCheckLinearFilter())
    {
        pTexture->setMinificationFilter(QOpenGLTexture::Nearest);
        pTexture->setMagnificationFilter(QOpenGLTexture::Linear);
    }
    doneCurrent();
    return m_pTextureCacheManager->add(pTexture);
}
void MyWindow::PrepareTexture(GLenum TextureTarget, const QString& FileName, GLuint& TexObject, bool flip)
{
    QImage TexImg;

    if (!TexImg.load(FileName)) qDebug() << "Erreur chargement texture";
    if (flip==true) TexImg=TexImg.mirrored();

    glGenTextures(1, &TexObject);
    glBindTexture(TextureTarget, TexObject);
    glTexImage2D(TextureTarget, 0, GL_RGB, TexImg.width(), TexImg.height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, TexImg.bits());
    glTexParameterf(TextureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(TextureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
Пример #21
0
/*!
    This slot is used to recieve signals from the QDownloadManager class
    which provides Url download capability across the network.

    A successful download will have a valid QByteArray stored in \a assetData,
    while a failed download (due to network error, etc), will result in
    a NULL value.

    Successful downloads use the image data downloaded into \a assetData,
    which is converted to an image/texture, and emit a textureUpdated()
    signal.

    \sa QDownloadManager
*/
void QGLTexture2D::textureRequestFinished(QByteArray assetData)
{
    //Ensure valid asset data exists.
    if (assetData.isEmpty()) {
        qWarning("Network request failed. Texture not loaded.");
    } else {
        //Convert asset data to an image.
        QImage texImage;
        texImage.loadFromData(assetData);
        setImage(texImage.mirrored());

        emit textureUpdated();
    }
}
Пример #22
0
QPixmap DrawFractal::Draw_IFS(int w, int h, float x, float y, float cx, float cy)
{
    QPixmap pixmap(w,h);
    pixmap.fill();
    QPainter painter(&pixmap);
    QPen pen; //»­±Ê
    pen.setColor(QColor(255,0,0));
    painter.setPen(pen); //Ìí¼Ó»­±Ê

    for(int i = 0;i < 1000;i++)
    {
        int m = (x + 2.0) * w / 4.0;
        int n = (y + 1.0) * h / 2.0;

        qDebug() << m << n;

        painter.drawPoint(m ,n);
        //painter.drawRect(m - 3,n - 3,m + 3,n + 3);

        float wx = x - cx;
        float wy = y - cy;

        float theta;

        if( wx > 0 )
            theta = atan( wy / wx );
        if( wx < 0 )
            theta = atan( wy / wx ) + PI;
        if( wx == 0 )
            theta = PI / 2;

        theta /= 2.0;

        float r = sqrt( wx * wx + wy * wy);
        float k = rand() % 100000 / 100000.0;
        if( k < 0.5 )
            r = sqrt( r );
        else
            r = -sqrt( r );

        x = r * cos( theta );
        y = r * sin( theta );
    }

    QImage img = pixmap.toImage();
    img = img.mirrored();

    return QPixmap::fromImage(img);//.scaled(w,h);
}
Пример #23
0
void QtOpenCVViewerGl::renderImage()
{
    makeCurrent();

    if (!mRenderQtImg.isNull())
    {
        glLoadIdentity();

        QImage image; // the image rendered

        glPushMatrix();
        {
            int imW = mRenderQtImg.width();
            int imH = mRenderQtImg.height();

            // The image is to be resized to fit the widget?
            if( imW != this->size().width() &&
                    imH != this->size().height() )
            {

                image = mRenderQtImg.scaled( //this->size(),
                                             QSize(mOutW,mOutH),
                                             Qt::IgnoreAspectRatio,
                                             Qt::SmoothTransformation
                                             );

                //qDebug( QString( "Image size: (%1x%2)").arg(imW).arg(imH).toAscii() );
            }
            else
                image = mRenderQtImg;

            // ---> Centering image in draw area

            glRasterPos2i( mPosX, mPosY );
            // <--- Centering image in draw area

            image = image.mirrored(true,false);

            imW = image.width();
            imH = image.height();

            glDrawPixels( imW, imH, GL_RGBA, GL_UNSIGNED_BYTE, image.bits());
        }
        glPopMatrix();

        // end
        glFlush();
    }
}
Пример #24
0
const QPixmap Tilesheet::getTileByIndexOrient(unsigned char index, TileOrient orient) const {
	QImage image = texture.copy(tileTexCoords[index]).toImage();
	QTransform trans;
	
	switch(orient) {
		case TILE_ORIENT_NORMAL:
			break;
		case TILE_ORIENT_ROT_90:
			trans.rotate(-90.0);
			break;
		case TILE_ORIENT_ROT_180:
			trans.rotate(-180.0);
			break;
		case TILE_ORIENT_ROT_270:
			trans.rotate(-270.0);
			break;
		case TILE_ORIENT_FLIP_H:
			image = image.mirrored(true, false);
			break;
		case TILE_ORIENT_FLIP_V:
			image = image.mirrored(false, true);
			break;
		case TILE_ORIENT_FH_90:
			image = image.mirrored(true, false);
			trans.rotate(-90.0);
			break;
		case TILE_ORIENT_FH_270:
			image = image.mirrored(true, false);
			trans.rotate(-270.0);
			break;
		default:
			break;
	}
	
	return QPixmap::fromImage(image.transformed(trans));
}
Пример #25
0
void CGLWidget::loadGLTexture()
{
    QImage buff;
    if(!buff.load(":/media/uvmap.DDS"))
    {
        qDebug() << "can't load texture file...";
        QImage dummy(128, 128, QImage::Format::Format_RGB32);
        dummy.fill(QColor(Qt::green).rgb());
        buff = dummy;
    }

    m_texture = new QOpenGLTexture(buff.mirrored());
    m_texture->setMagnificationFilter(QOpenGLTexture::Linear);
    m_texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
}
Пример #26
0
QImage WelcomeItem::reflection(QImage &img) {
  QImage reflect = img.mirrored(0, 1);
  QPainter p(&reflect);
  QPoint x, y;

  y.setY(reflect.height());
  QLinearGradient grad(x, y);
  grad.setColorAt(0, QColor(0, 0, 0, 95));
  grad.setColorAt(1, Qt::transparent);
  p.setCompositionMode(QPainter::CompositionMode_DestinationIn);

  p.fillRect(QRect(0, 0, reflect.width(), reflect.height()), grad);
  p.end();
  return reflect;
}
Пример #27
0
void PictureLoader::imageLoaded(CardInfo *card, const QImage &image)
{
    if(image.isNull())
        return;

    if(card->getUpsideDownArt())
    {
        QImage mirrorImage = image.mirrored(true, true);
        QPixmapCache::insert(card->getPixmapCacheKey(), QPixmap::fromImage(mirrorImage));
    } else {
        QPixmapCache::insert(card->getPixmapCacheKey(), QPixmap::fromImage(image));
    }

    card->emitPixmapUpdated();
}
Пример #28
0
void ImageView::rotateByExifRotation(QImage &image, QString &imageFullPath)
{
	QTransform trans;
	int orientation = mdCache->getImageOrientation(imageFullPath);

	switch(orientation) {
		case 2:
			image = image.mirrored(true, false);
			break;
		case 3:
			trans.rotate(180);
			image = image.transformed(trans, Qt::SmoothTransformation);
			break;
		case 4:
			image = image.mirrored(false, true);
			break;
		case 5:
			trans.rotate(90);
			image = image.transformed(trans, Qt::SmoothTransformation);
			image = image.mirrored(true, false);
			break;
		case 6:
			trans.rotate(90);
			image = image.transformed(trans, Qt::SmoothTransformation);
			break;
		case 7:
			trans.rotate(90);
			image = image.transformed(trans, Qt::SmoothTransformation);
			image = image.mirrored(false, true);
			break;
		case 8:
			trans.rotate(270);
			image = image.transformed(trans, Qt::SmoothTransformation);
			break;
	}
}
Пример #29
0
void MyWindow::PrepareTexture(GLenum TextureUnit, GLenum TextureTarget, const QString& FileName, bool flip)
{
    QImage TexImg;

    if (!TexImg.load(FileName)) qDebug() << "Erreur chargement texture " << FileName;
    if (flip==true) TexImg=TexImg.mirrored();

    glActiveTexture(TextureUnit);
    GLuint TexID;
    glGenTextures(1, &TexID);
    glBindTexture(TextureTarget, TexID);
    mFuncs->glTexStorage2D(TextureTarget, 1, GL_RGBA8, TexImg.width(), TexImg.height());
    mFuncs->glTexSubImage2D(TextureTarget, 0, 0, 0, TexImg.width(), TexImg.height(), GL_BGRA, GL_UNSIGNED_BYTE, TexImg.bits());
    //glTexImage2D(TextureTarget, 0, GL_RGB, TexImg.width(), TexImg.height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, TexImg.bits());
    glTexParameteri(TextureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(TextureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
Пример #30
0
//重写绘图事件
void DeskTopSprite::paintEvent(QPaintEvent *)
{
	float nowTime = timer.elapsed()/1000.f;
	deltaTime = nowTime - lastTime;
	FrameUpdate();
	QPainter painter(this);

	for (size_t i = 0;i< renderQueue.size();i++)
	{
		RenderData& data = renderQueue[i];
		QImage img = data.pic->toImage();
		painter.drawImage(data.x,data.y,img.mirrored(data.bMirror, false));
	}

	renderQueue.clear();

	lastTime = nowTime;
}