当前位置: 首页>>代码示例>>C++>>正文


C++ BitmapImage::pixel方法代码示例

本文整理汇总了C++中BitmapImage::pixel方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapImage::pixel方法的具体用法?C++ BitmapImage::pixel怎么用?C++ BitmapImage::pixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitmapImage的用法示例。


在下文中一共展示了BitmapImage::pixel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mouseReleaseEvent

void EyedropperTool::mouseReleaseEvent(QMouseEvent *event)
{
    Layer* layer = mEditor->layers()->currentLayer();
    if (layer == NULL) { return; }

    if (event->button() == Qt::LeftButton)
    {
        if (layer->type() == Layer::BITMAP)
        {
            BitmapImage* targetImage = ((LayerBitmap *)layer)->getLastBitmapImageAtFrame( mEditor->currentFrame(), 0);
            //QColor pickedColour = targetImage->pixel(getLastPoint().x(), getLastPoint().y());
            QColor pickedColour;
            pickedColour.setRgba( targetImage->pixel( getLastPoint().x(), getLastPoint().y() ) );
            int transp = 255 - pickedColour.alpha();
            pickedColour.setRed( pickedColour.red() + transp );
            pickedColour.setGreen( pickedColour.green() + transp );
            pickedColour.setBlue( pickedColour.blue() + transp );
            if (pickedColour.alpha() != 0)
            {
                mEditor->color()->setColor(pickedColour);
            }
        }
        else if (layer->type() == Layer::VECTOR)
        {
            VectorImage *vectorImage = ((LayerVector *)layer)->getLastVectorImageAtFrame(mEditor->currentFrame(), 0);
            int colourNumber = vectorImage->getColourNumber(getLastPoint());
            if (colourNumber != -1)
            {
                mEditor->color()->setColorNumber(colourNumber);
            }
        }
    }
}
开发者ID:GraphiXS6,项目名称:pencil,代码行数:33,代码来源:eyedroppertool.cpp

示例2: mouseMoveEvent

void EyedropperTool::mouseMoveEvent(QMouseEvent *event)
{
    Q_UNUSED(event);

    Layer* layer = mEditor->layers()->currentLayer();
    if (layer == NULL) { return; }

    if (layer->type() == Layer::BITMAP)
    {
        BitmapImage *targetImage = ((LayerBitmap *)layer)->getLastBitmapImageAtFrame(mEditor->currentFrame(), 0);
        if (targetImage->contains(getCurrentPoint()))
        {
            QColor pickedColour;
            //pickedColour.setRgba(targetImage->pixel(getCurrentPoint().x(), getCurrentPoint().y()));
            pickedColour.setRgba( targetImage->pixel( getCurrentPoint().x(), getCurrentPoint().y() ) );
            int transp = 255 - pickedColour.alpha();
            pickedColour.setRed( pickedColour.red() + transp );
            pickedColour.setGreen( pickedColour.green() + transp );
            pickedColour.setBlue( pickedColour.blue() + transp );
            if (pickedColour.alpha() != 0)
            {
                mScribbleArea->setCursor(cursor(pickedColour));
            }
            else
            {
                mScribbleArea->setCursor(cursor());
            }
        }
        else
        {
            mScribbleArea->setCursor(cursor());
        }
    }
    if (layer->type() == Layer::VECTOR)
    {
        VectorImage *vectorImage = ((LayerVector *)layer)->getLastVectorImageAtFrame(mEditor->currentFrame(), 0);
        int colourNumber = vectorImage->getColourNumber(getCurrentPoint());
        if (colourNumber != -1)
        {
            mScribbleArea->setCursor(cursor(mEditor->object()->getColour(colourNumber).colour));
        }
        else
        {
            mScribbleArea->setCursor(cursor());
        }
    }
}
开发者ID:GraphiXS6,项目名称:pencil,代码行数:47,代码来源:eyedroppertool.cpp

示例3: floodFill

void BitmapImage::floodFill(BitmapImage* targetImage, BitmapImage* fillImage, QPoint point, QRgb targetColour, QRgb replacementColour, int tolerance, bool extendFillImage)
{
    QList<QPoint> queue; // queue all the pixels of the filled area (as they are found)
    int j, k;
    bool condition;
    BitmapImage* replaceImage;
    if (extendFillImage)
    {
        replaceImage = new BitmapImage(targetImage->mBounds.united(fillImage->mBounds), QColor(0,0,0,0));
    }
    else
    {
        targetImage->extend(fillImage->mBounds); // not necessary - here just to prevent some bug when we draw outside the targetImage - to be fixed
        replaceImage = new BitmapImage(fillImage->mBounds, QColor(0,0,0,0));
        replaceImage->mExtendable = false;
    }
    //QPainter painter1(replaceImage->image);
    //QPainter painter2(fillImage->image);
    //painter1.setPen( QColor(replacementColour) );
    QPen myPen;
    myPen = QPen( QColor(replacementColour) , 1.0, Qt::SolidLine, Qt::RoundCap,Qt::RoundJoin);

    targetColour = targetImage->pixel(point.x(), point.y());
    //if (  rgbDistance(targetImage->pixel(point.x(), point.y()), targetColour) > tolerance ) return;
    queue.append( point );
    // ----- flood fill
    // ----- from the standard flood fill algorithm
    // ----- http://en.wikipedia.org/wiki/Flood_fill
    j = -1;
    k = 1;
    for(int i=0; i< queue.size(); i++ )
    {
        point = queue.at(i);
        if (  replaceImage->pixel(point.x(), point.y()) != replacementColour  && rgbDistance(targetImage->pixel(point.x(), point.y()), targetColour) < tolerance )
        {
            j = -1;
            condition =  (point.x() + j > targetImage->left());
            if (!extendFillImage) condition = condition && (point.x() + j > replaceImage->left());
            while ( replaceImage->pixel(point.x()+j, point.y()) != replacementColour  && rgbDistance(targetImage->pixel( point.x()+j, point.y() ), targetColour) < tolerance && condition)
            {
                j = j - 1;
                condition =  (point.x() + j > targetImage->left());
                if (!extendFillImage) condition = condition && (point.x() + j > replaceImage->left());
            }

            k = 1;
            condition = ( point.x() + k < targetImage->right()-1);
            if (!extendFillImage) condition = condition && (point.x() + k < replaceImage->right()-1);
            while ( replaceImage->pixel(point.x()+k, point.y()) != replacementColour  && rgbDistance(targetImage->pixel( point.x()+k, point.y() ), targetColour) < tolerance && condition)
            {
                k = k + 1;
                condition = ( point.x() + k < targetImage->right()-1);
                if (!extendFillImage) condition = condition && (point.x() + k < replaceImage->right()-1);
            }

            //painter1.drawLine( point.x()+j, point.y(), point.x()+k+1, point.y() );

            replaceImage->drawLine( QPointF(point.x()+j, point.y()), QPointF(point.x()+k, point.y()), myPen, QPainter::CompositionMode_SourceOver, false);
            //for(int l=0; l<=k-j+1 ; l++) {
            //	replaceImage->setPixel( point.x()+j, point.y(), replacementColour );
            //}

            for(int x = j+1; x < k; x++)
            {
                //replaceImage->setPixel( point.x()+x, point.y(), replacementColour);
                condition = point.y() - 1 > targetImage->top();
                if (!extendFillImage) condition = condition && (point.y() - 1 > replaceImage->top());
                if ( condition && queue.size() < targetImage->height() * targetImage->width() )
                {
                    if ( replaceImage->pixel(point.x()+x, point.y()-1) != replacementColour)
                    {
                        if (rgbDistance(targetImage->pixel( point.x()+x, point.y() - 1), targetColour) < tolerance)
                        {
                            queue.append( point + QPoint(x,-1) );
                        }
                        else
                        {
                            replaceImage->setPixel( point.x()+x, point.y()-1, replacementColour);
                        }
                    }
                }
                condition = point.y() + 1 < targetImage->bottom();
                if (!extendFillImage) condition = condition && (point.y() + 1 < replaceImage->bottom());
                if ( condition && queue.size() < targetImage->height() * targetImage->width() )
                {
                    if ( replaceImage->pixel(point.x()+x, point.y()+1) != replacementColour)
                    {
                        if (rgbDistance(targetImage->pixel( point.x()+x, point.y() + 1), targetColour) < tolerance)
                        {
                            queue.append( point + QPoint(x, 1) );
                        }
                        else
                        {
                            replaceImage->setPixel( point.x()+x, point.y()+1, replacementColour);
                        }
                    }
                }
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:meiavy,项目名称:pencil-1,代码行数:101,代码来源:bitmapimage.cpp


注:本文中的BitmapImage::pixel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。