⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qpixmap.3qt

📁 qt-embedded-2.3.8.tar.gz源码
💻 3QT
📖 第 1 页 / 共 3 页
字号:
.PPSee also isNull()..SH "QPixmap::QPixmap ( const QByteArray & img_data )"Constructs a pixmaps by loading from \fIimg_data.\fR The data can be in any image format supported by Qt..PPSee also loadFromData()..SH "QPixmap::QPixmap ( const QString & fileName, const char * format, int conversion_flags )"Constructs a pixmap from the file \fIfileName.\fR If the file does not exist, or is of an unknown format, the pixmap becomes a null pixmap..PPThe parameters are passed on to load()..PPSee also isNull(), load(), loadFromData(), save() and imageFormat()..SH "QPixmap::QPixmap ( const QString & fileName, const char * format=0, ColorMode mode=Auto )"Constructs a pixmap from the file \fIfileName.\fR If the file does not exist, or is of an unknown format, the pixmap becomes a null pixmap..PPThe parameters are passed on to load()..PPSee also isNull(), load(), loadFromData(), save() and imageFormat()..SH "QPixmap::QPixmap ( const QPixmap & pixmap )"Constructs a pixmap which is a copy of \fIpixmap.\fR.SH "QPixmap::QPixmap ( const char * xpm[] )"Constructs a pixmap from \fIxpm,\fR which must be a valid XPM image..PPError are silently ignored..PPNote that it's possible to squeeze the XPM variable a little bit by using an unusual declaration:.PP.nf.br    static const char * const start_xpm[]={.br        "16 15 8 1",.br        "a c #cec6bd",.br    .....fi.PPThe extra \fCconst\fR makes the entire definition read-only, which is slightly more efficient e.g. when the code is in a shared library, and ROMable when the application is to be stored in ROM..PPIn order to use that sort of declaration, you must cast the variable back to <nobr>\fCconst char **\fR</nobr> when you create the QPixmap..SH "QPixmap::QPixmap ( int w, int h, const uchar * bits, bool isXbitmap ) \fC[protected]\fR"Constructs a monochrome pixmap which is initialized with the data in \fIbits.\fR This constructor is protected and used by the QBitmap class..SH "QPixmap::QPixmap ( int w, int h, int depth = -1, Optimization optimization = DefaultOptim )"Constructs a pixmap with \fIw\fR width, \fIh\fR height and of \fIdepth\fR bits per pixels..PPThe contents of the pixmap is uninitialized..PPThe \fIdepth\fR can be either 1 (monochrome) or the depth of the current video mode. If \fIdepth\fR is negative, then the hardware depth of the current video mode will be used..PPIf either \fIwidth\fR or \fIheight\fR is zero, a null pixmap is constructed..PPSee also isNull()..SH "QPixmap::QPixmap ( const QSize & size, int depth = -1, Optimization optimization = DefaultOptim )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QPixmap::~QPixmap ()"Destructs the pixmap..SH "bool QPixmap::convertFromImage ( const QImage & img, int conversion_flags )"Converts an image and sets this pixmap. Returns TRUE if successful..PPThe \fIconversion_flags\fR argument is a bitwise-OR from the following choices. The options marked \fI(default)\fR are the choice if no other choice from the list is included (they are zero):.IP "Color/Mono preference (ignored for QBitmap)" 1c.TP\fCAutoColor\fR (default) - If the \fIimage\fR has depth 1 and contains only black and white pixels, then the pixmap becomes monochrome..TP\fCColorOnly\fR - The pixmap is dithered/converted to the native display depth..TP\fCMonoOnly\fR - The pixmap becomes monochrome. If necessary, it is dithered using the chosen dithering algorithm..IP "Dithering mode preference, for RGB channels" 1c.TP\fCDiffuseDither\fR (default) - a high quality dither.TP\fCOrderedDither\fR - a faster more ordered dither.TP\fCThresholdDither\fR - no dithering, closest color is used.IP "Dithering mode preference, for alpha channel" 1c.TP\fCDiffuseAlphaDither\fR - a high quality dither.TP\fCOrderedAlphaDither\fR - a faster more ordered dither.TP\fCThresholdAlphaDither\fR (default) - no dithering.IP "Color matching versus dithering preference" 1c.TP\fCPreferDither\fR - always dither 32-bit images when the image is being converted to 8-bits. This is the default when converting to a pixmap..TP\fCAvoidDither\fR - only dither 32-bit images if the image has more than 256 colors and it is being converted to 8-bits. This is the default when an image is converted for the purpose of saving to a file..PPPassing 0 for \fIconversion_flags\fR gives all the default options..PPNote that even though a QPixmap with depth 1 behaves much like a QBitmap, isQBitmap() returns FALSE..PPIf a pixmap with depth 1 is painted with color0 and color1 and converted to an image, the pixels painted with color0 will produce pixel index 0 in the image and those painted with color1 will produce pixel index 1..PPSee also convertToImage(), isQBitmap(), QImage::convertDepth(), defaultDepth() and QImage::hasAlphaBuffer()..PPBugs and limitations:.TPDoes not support 2 or 4 bit display hardware..PPExamples:.(lqtimage/qtimage.cpp.)l.SH "bool QPixmap::convertFromImage ( const QImage & image, ColorMode mode=Auto )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QImage QPixmap::convertToImage () const"Converts the pixmap to an image. Returns a null image if the operation failed..PPIf the pixmap has 1 bit depth, the returned image will also be 1 bits deep. If the pixmap has 2-8 bit depth, the returned image has 8 bit depth. If the pixmap has greater than 8 bit depth, the returned image has 32 bit depth..PPSee also convertFromImage()..PPBugs and limitations:.TPDoes not support 2 or 4 bit display hardware..TPAlpha masks on monochrome images are ignored..PPExamples:.(lqmag/qmag.cpp.)l.SH "QBitmap QPixmap::createHeuristicMask ( bool clipTight = TRUE ) const"Creates and returns a heuristic mask for this pixmap. It works by selecting a color from one of the corners, then chipping away pixels of that color, starting at all the edges..PPThe mask may not be perfect but should be reasonable, so you can do things like:.PP.nf.br    pm->setMask( pm->createHeuristicMask() );.fi.PPThis function is slow because it involves transformation to a QImage, non-trivial computations and a transformation back to QBitmap..PPSee also QImage::createHeuristicMask()..SH "int QPixmap::defaultDepth () \fC[static]\fR"Returns the default pixmap depth, i.e. the depth a pixmap gets if -1 is specified..PPSee also depth()..SH "QPixmap::Optimization QPixmap::defaultOptimization() \fC[static]\fR"Returns the default pixmap optimization setting..PPSee also setDefaultOptimization(), setOptimization() and optimization()..SH "int QPixmap::depth () const"Returns the depth of the image..PPThe pixmap depth is also called bits per pixel (bpp) or bit planes of a pixmap. A null pixmap has depth 0..PPSee also defaultDepth(), isNull() and QImage::convertDepth()..SH "void QPixmap::detach () \fC[virtual]\fR"Special-purpose function that detaches the pixmap from shared pixmap data..PPA pixmap is automatically detached by Qt whenever its contents is about to change. This is done in all QPixmap member functions that modify the pixmap (fill(), resize(), convertFromImage(), load() etc.), in bitBlt() for the destination pixmap and in QPainter::begin() on a pixmap..PPIt is possible to modify a pixmap without letting Qt know. You can first obtain the system-dependent handle and then call system-specific functions (for instance BitBlt under Windows) that modifies the pixmap contents. In this case, you can call detach() to cut the pixmap loose from other pixmaps that share data with this one..PPdetach() returns immediately if there is just a single reference or if the pixmap has not been initialized yet..SH "void QPixmap::fill ( const QColor & fillColor = Qt::white )"Fills the pixmap with the color \fIfillColor.\fR.PPExamples:.(lxform/xform.cpp desktop/desktop.cpp.)l.SH "void QPixmap::fill ( const QWidget * widget, const QPoint & ofs )"Fills the pixmap with the widget's background color or pixmap. If the background is empty, nothing is done..PPThe \fIofs\fR point is an offset in the widget..PPThe point \fIofs\fR is a point in the widget's coordinate system. The pixmap's top left pixel will be mapped to the point \fIofs\fR in the widget. This is significant if the widget has a background pixmap, otherwise the pixmap will simply be filled with the background color of the widget..PPExample:.PP.nf.br  void CuteWidget::paintEvent( QPaintEvent *e ).br  {.br    QRect ur = e->rect();               // rectangle to update.br.br    QPixmap  pix( ur.size() );          // Pixmap for double-buffering.br.br    pix.fill( this, ur.topLeft() );     // fill with widget background.br.br    QPainter p( &pix );.br    p.translate( -ur.x(), -ur.y() );    // use widget coordinate system.br                                        // when drawing on pixmap.br    //    ... draw on pixmap ....br.br    p.end();.br.br    bitBlt( this, ur.topLeft(), &pix );.br  }.fi.SH "void QPixmap::fill ( const QWidget * widget, int xofs, int yofs )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QPixmap QPixmap::grabWidget ( QWidget * widget, int x=0, int y=0, int w=-1, int h=-1 ) \fC[static]\fR"Creates a pixmap and paints \fIwidget\fR in it..PPIf \fIwidget\fR has children, they are painted too, appropriately located..PPIf you specify \fIx, y, w\fR or \fIh,\fR only the rectangle you specify is painted. The defaults are 0, 0 (top-left corner) and -1,-1 (which means the entire widget)..PP(If \fIw\fR is negative, the function copies everything to the right border of the window. If \fIh\fR is negative, the function copies everything to the bottom of the window.).PPIf \fIwidget\fR is 0, or if the rectangle defined by \fIx, y,\fR the modified \fIw\fR and the modified \fIh\fR does not overlap the \fIwidget->rect(),\fR this function returns a null QPixmap..PPThis function actually asks \fIwidget\fR to paint itself (and its children to paint themselves). QPixmap::grabWindow() grabs pixels off the screen, which is a bit faster and picks up \fIexactly\fR what's on-screen. This function works by calling paintEvent() with painter redirection turned on, which gets the result of paintEvent(), without e.g. overlying windows..PPIf there is overlap, it returns a pixmap of the size you want, containing a rendering of \fIwidget.\fR If the rectangle you ask for is a superset of \fIwidget,\fR the area outside \fIwidget\fR are covered with the widget's background..PPSee also grabWindow(), QPainter::redirect() and QWidget::paintEvent()..SH "QPixmap QPixmap::grabWindow ( WId window, int x=0, int y=0, int w=-1, int h=-1 ) \fC[static]\fR"Grabs the contents of a window and makes a pixmap out of it. Returns the pixmap..PPThe arguments \fI(x,y)\fR specify the offset in the window, while \fI(w,h)\fR specify the width and height of the area to be copied..PPIf \fIw\fR is negative, the function copies everything to the right border of the window. If \fIh\fR is negative, the function copies everything to the bottom of the window..PPNote that grabWindows() grabs pixels from the screen, not from the window. This means that If there is another window partially or entirely over the one you grab, you get pixels from the overlying window too..PPNote also that the mouse cursor is generally not grabbed..PPThe reason we use a window identifier and not a QWidget is to enable grabbing of windows that are not part of the application, window system frames, and so on..PP\fBWarning:\fR Grabbing an area outside the screen is not safe in general. This depends on the underlying window system..PPSee also grabWidget()..SH "int QPixmap::height () const"Returns the height of the pixmap..PPSee also width(), size() and rect()..PPExamples:.(lmovies/main.cpp qtimage/qtimage.cpp scrollview/scrollview.cpp xform/xform.cpp desktop/desktop.cpp.)l.SH "const char* QPixmap::imageFormat ( const QString & fileName ) \fC[static]\fR"Returns a string that specifies the image format of the file \fIfileName,\fR or null if the file cannot be read or if the format cannot be recognized..PPThe QImageIO documentation lists the supported image formats..PPSee also load() and save()..SH "bool QPixmap::isNull () const"Returns TRUE if it is a null pixmap..PPA null pixmap has zero width, zero height and no contents. You cannot draw in a null pixmap or bitBlt() anything to it..PPResizing an existing pixmap to (0,0) makes a pixmap into a null pixmap..PPSee also resize()..PPExamples:.(lscrollview/scrollview.cpp qmag/qmag.cpp.)l.SH "bool QPixmap::isQBitmap () const"Returns TRUE if this is a QBitmap, otherwise FALSE..SH "bool QPixmap::load ( const QString & fileName, const char * format, int conversion_flags )"Loads a pixmap from the file \fIfileName.\fR Returns TRUE if successful, or FALSE if the pixmap could not be loaded.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -