Erase Tool Wont Erase Only Draw

Draw a wrinkle on the QPixmap occupied with transparent with a red brush. Now you take to erase part of the red to restore the innovational transparent color.

Use QPainter::CompositionMode ikon overlay mode

The following plot simply illustrates 10 modes:

In Qt's official certification, we also constitute an explanation of specific modes

Constant

Value

Verbal description

QPainter::CompositionMode_SourceOver

0

This is the default option way. The alpha of the source is used to blend the picture element on top of the destination.

QPainter::CompositionMode_DestinationOver

1

The alpha of the name and address is used to blend it happening top of the source pixels. This mode is the inverse of CompositionMode_SourceOver.

QPainter::CompositionMode_Clear

2

The pixels in the destination are clear (set to in full transparent) absolute of the source.

QPainter::CompositionMode_Source

3

The output is the source pel. (This agency a basic copy surgical operation and is identical to SourceOver when the source pixel is unintelligible).

QPainter::CompositionMode_Destination

4

The output is the destination pixel. This means that the merging has no effect. This mode is the inverse of CompositionMode_Source.

QPainter::CompositionMode_SourceIn

5

The output is the source, where the alpha is reduced by that of the destination.

QPainter::CompositionMode_DestinationIn

6

The outturn is the goal, where the alpha is reduced away that of the source. This mode is the opposite of CompositionMode_SourceIn.

QPainter::CompositionMode_SourceOut

7

The output is the source, where the alpha is reduced by the opposite of destination.

QPainter::CompositionMode_DestinationOut

8

The output signal is the destination, where the alpha is reduced aside the inverse of the source. This mode is the reciprocal of CompositionMode_SourceOut.

QPainter::CompositionMode_SourceAtop

9

The author pel is homogenised on top off of the destination, with the alpha of the source pixel reduced aside the alpha of the destination pixel.

QPainter::CompositionMode_DestinationAtop

10

The destination pel is mingling on top of the source, with the exploratory of the destination picture element is reduced past the alpha of the destination pixel. This mode is the reciprocal of CompositionMode_SourceAtop.

QPainter::CompositionMode_Xor

11

The informant, whose alpha is reduced with the opposite of the destination important, is merged with the destination, whose exploratory is reduced by the inverse of the source explorative. CompositionMode_Xor is non the same as the bitwise Xor.

QPainter::CompositionMode_Clear can exist cleared and occupied with transparent colour, which is the style we need.

          /*     Socialistic mouse button is for drawing, right button is for erasing        int leftorright way left and reactionist mouse buttons        leftorright = 1; //The left button was pressed        leftorright = 2; //The letter-perfect button is pressed   */          QPainter *Felis concolor = new QPainter; //Create a newly QPainter objective          QPen pen; //Create a New QPen object        //Arrange the line elan of the brush, style indicates that the presently selected stemma style is Qt::PenStyle enumerates the few elements in the information     pen.setStyle ((Qt::PenStyle)1);         if (leftorright == 1)                                   {                      pen.setWidth (2); //Set the line breadth of the penitentiary                  pen.setColor (Qt::reddish); //Set the discolour of the pen         painter -> begin(pix);                  //Use CompositionMode_DestinationOver mode when draftsmanship         painter -> setCompositionMode(QPainter::CompositionMode_DestinationOver);                  painter -> setPen(compose); //Apply QPen objects to key objects                  //Draw a full-strength line from startPos to the up-to-the-minute set up of the mouse         painter -> drawLine(startPos, e->pos());                  painter -> goal(); //Return true after successful drawing     }     else if (leftorright == 2)                             {                  pen.setWidth(5); //The copse is slightly thicker when erasing         painter -> begin(pix);                  //Set to authorise mode, score out with gauze-like color         painter -> setCompositionMode(QPainter::CompositionMode_Clear);                  panther -> setPen(pen); //Apply QPen objects to paint objects                  //Draw a heterosexual person melody from startPos to the new position of the mouse         painter -> drawLine(startPos, e->pos());                  mountain lion -> end(); //Getting even true after productive draft     }     /***            * Draw with QPixmap aim as QPaintDevice parameter, construct a QPainter object,            * Immediately start drawing on the painting equipment, this social organization QPainter object is short-term            * Because the constructor cannot leave feedback when the initialisation of a QPainter objective fails,            * So when drawing external devices, you should use begin() and end() (Ps: so much as printer outside devices)      */          startPos = e -> pos(); //Update the live position of the sneak out to prepare for the next drawing          update(); //Redraw the drawing area form        

problem:

The console keeps outputting while running: QPainter::setCompositionMode: Felis concolor not active

This indicates that the operation of QPainter has not taken upshot.

solve:

Totally operations on QPainter objects should be placed between QPainter objects Menachem Begin() and end() to take effect.

Erase with Brush Tool in PhotoShop

Recently watched a course, use the slope creature to generate a rainbow, and practice the brush creature to wipe out part of the image 1. First, tote up a layer to the image 2. Use the gradient puppet to generate a rain...

Erase Tool Wont Erase Only Draw

Source: https://programmersought.com/article/20564070767/

0 Response to "Erase Tool Wont Erase Only Draw"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel