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

📄 showimg-main-cpp.html

📁 qtopiaphone英文帮助,用于初学者和开发人员,初学者可以用来学习,开发人员可以用来资料查询.
💻 HTML
📖 第 1 页 / 共 3 页
字号:
        } else {            <a href="qwmatrix.html">QWMatrix</a> m;                         // transformation matrix            m.<a href="qwmatrix.html#41a356">scale</a>(((double)width())/pm.width(),// define scale factors                    ((double)h)/pm.height());            pmScaled = pm.xForm( m );           // create scaled pixmap        }    }    <a href="qapplication.html#655095">QApplication::restoreOverrideCursor</a>();      // restore original cursor}/*  The resize event handler, if a valid pixmap was loaded it will call  <a href=#381>scale</a>() to fit the pixmap to the new widget size.*/void <a name="382"></a>ImageViewer::resizeEvent( <a href="qresizeevent.html">QResizeEvent</a> * ){    status-&gt;setGeometry(0, <a href="qwidget.html#e3c588">height</a>() - status-&gt;height(),                        <a href="qwidget.html#2edab1">width</a>(), status-&gt;height());    if ( pm.size() == QSize( 0, 0 ) )           // we couldn't load the image        return;    int h = height() - menubar-&gt;heightForWidth( <a href="qwidget.html#2edab1">width</a>() ) - status-&gt;height();    if ( width() != pmScaled.width() || h != pmScaled.height())    {                                           // if new size,        <a href=#381>scale</a>();                                // scale pmScaled to window        <a href=#371>updateStatus</a>();    }    if ( image.hasAlphaBuffer() )        <a href="qwidget.html#10cf79">erase</a>();}bool <a name="383"></a>ImageViewer::convertEvent( <a href="qmouseevent.html">QMouseEvent</a>* e, int&amp; x, int&amp; y){    if ( pm.size() != QSize( 0, 0 ) ) {        int h = height() - menubar-&gt;heightForWidth( <a href="qwidget.html#2edab1">width</a>() ) - status-&gt;height();        int nx = e-&gt;x() * image.width() / width();        int ny = (e-&gt;y()-menubar-&gt;heightForWidth( <a href="qwidget.html#2edab1">width</a>() )) * image.height() / h;        if (nx != x || ny != y ) {            x = nx;            y = ny;            <a href=#371>updateStatus</a>();            return TRUE;        }    }    return FALSE;}void <a name="384"></a>ImageViewer::mousePressEvent( <a href="qmouseevent.html">QMouseEvent</a> *e ){    may_be_other = convertEvent(e, clickx, clicky);}void <a name="385"></a>ImageViewer::mouseReleaseEvent( <a href="qmouseevent.html">QMouseEvent</a> * ){    if ( may_be_other )        other = this;}/*  Record the pixel position of interest.*/void <a name="386"></a>ImageViewer::mouseMoveEvent( <a href="qmouseevent.html">QMouseEvent</a> *e ){    if (convertEvent(e,pickx,picky)) {        <a href=#371>updateStatus</a>();        if ((e-&gt;state()&amp;LeftButton)) {            may_be_other = FALSE;            if ( clickx &gt;= 0 &amp;&amp; other) {                <a href=#389>copyFrom</a>(other);            }        }    }}/*  Draws the portion of the scaled pixmap that needs to be updated or prints  an error message if no legal pixmap has been loaded.*/void <a name="387"></a>ImageViewer::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> *e ){    if ( pm.size() != QSize( 0, 0 ) ) {         // is an image loaded?        <a href="qpainter.html">QPainter</a> painter(this);        painter.<a href="qpainter.html#898839">setClipRect</a>(e-&gt;<a href="qpaintevent.html#2d6e18">rect</a>());        painter.<a href="qpainter.html#c64b89">drawPixmap</a>(0, menubar-&gt;heightForWidth( <a href="qwidget.html#2edab1">width</a>() ), pmScaled);    }}/*  Explain anything that might be confusing.*/void <a name="388"></a>ImageViewer::giveHelp(){    if (!helpmsg) {        <a href="qstring.html">QString</a> helptext =            "&lt;b&gt;Usage:&lt;/b&gt; &lt;tt&gt;showimg [-m] &lt;i&gt;filename ...&lt;/i&gt;&lt;/tt&gt;"            "&lt;blockquote&gt;"                "&lt;tt&gt;-m&lt;/tt&gt; - use &lt;i&gt;ManyColor&lt;/i&gt; color spec"            "&lt;/blockquote&gt;"            "&lt;p&gt;Supported input formats:"            "&lt;blockquote&gt;";        helptext += QImage::inputFormatList().join(", ");        helptext += "&lt;/blockquote&gt;";        helpmsg = new <a href="qmessagebox.html">QMessageBox</a>( "Help", helptext,            QMessageBox::Information, QMessageBox::Ok, 0, 0, 0, 0, FALSE );    }    helpmsg-&gt;show();    helpmsg-&gt;raise();}void <a name="389"></a>ImageViewer::copyFrom(ImageViewer* s){    if ( clickx &gt;= 0 ) {        int dx = clickx;        int dy = clicky;        int sx = s-&gt;clickx;        int sy = s-&gt;clicky;        int sw = QABS(clickx - pickx)+1;        int sh = QABS(clicky - picky)+1;        if ( clickx &gt; pickx ) {            dx = pickx;            sx -= sw-1;        }        if ( clicky &gt; picky ) {            dy = picky;            sy -= sh-1;        }        <a href="qpaintdevice.html#35ae2e">bitBlt</a>( &amp;image, dx, dy, &amp;s-&gt;image, sx, sy, sw, sh );        <a href=#377>reconvertImage</a>();        <a href="qwidget.html#7569b1">repaint</a>( image.hasAlphaBuffer() );    }}ImageViewer* <a name="390"></a>ImageViewer::other = 0;void <a name="391"></a>ImageViewer::hFlip(){    <a href=#396>setImage</a>(image.mirror(TRUE,FALSE));}void <a name="392"></a>ImageViewer::vFlip(){    <a href=#396>setImage</a>(image.mirror(FALSE,TRUE));}void <a name="393"></a>ImageViewer::rot180(){    <a href=#396>setImage</a>(image.mirror(TRUE,TRUE));}void <a name="394"></a>ImageViewer::copy(){#ifndef QT_NO_MIMECLIPBOARD    <a href="qapplication.html#1c95b5">QApplication::clipboard</a>()-&gt;setImage(image); // Less information loss#endif}void <a name="395"></a>ImageViewer::paste(){#ifndef QT_NO_MIMECLIPBOARD    <a href="qimage.html">QImage</a> p = QApplication::clipboard()-&gt;image();    if ( !image.isNull() ) {        filename = "pasted";        <a href=#396>setImage</a>(p);    }#endif}void <a name="396"></a>ImageViewer::setImage(const QImage&amp; newimage){    image = newimage;    pickx = -1;    clickx = -1;    <a href="qwidget.html#d6a291">setCaption</a>( filename );                     // set window caption    int w = image.width();    int h = image.height();    if ( !w )        return;    const int reasonable_width = 128;    if ( w &lt; reasonable_width ) {        // Integer scale up to something reasonable        int multiply = ( reasonable_width + w - 1 ) / w;        w *= multiply;        h *= multiply;    }    h += menubar-&gt;heightForWidth(w) + status-&gt;height();    <a href="qwidget.html#8fcbbe">resize</a>( w, h );                             // we resize to fit image    <a href=#377>reconvertImage</a>();    <a href="qwidget.html#7569b1">repaint</a>( image.hasAlphaBuffer() );    <a href=#371>updateStatus</a>();    <a href=#370>setMenuItemFlags</a>();}void <a name="397"></a>ImageViewer::editText(){    ImageTextEditor editor(image,this);    editor.exec();}void <a name="398"></a>ImageViewer::to1Bit(){    <a href=#401>toBitDepth</a>(1);}void <a name="399"></a>ImageViewer::to8Bit(){    <a href=#401>toBitDepth</a>(8);}void <a name="400"></a>ImageViewer::to32Bit(){    <a href=#401>toBitDepth</a>(32);}void <a name="401"></a>ImageViewer::toBitDepth(int d){    image = image.convertDepth(d);    <a href=#377>reconvertImage</a>();    <a href="qwidget.html#7569b1">repaint</a>( image.hasAlphaBuffer() );}</pre>  <hr>  Main:<pre>/****************************************************************************** &#36;Id&#58; qt/examples/showimg/main.cpp   2.3.8   edited 2004-05-12 $**** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.**** This file is part of an example program for Qt.  This example** program may be used, distributed and modified without limitation.*******************************************************************************/#include "showimg.h"#include "imagefip.h"#include &lt;<a name="qapplication.h"></a><a href="qapplication-h.html">qapplication.h</a>&gt;#include &lt;<a name="qimage.h"></a><a href="qimage-h.html">qimage.h</a>&gt;int main( int argc, char **argv ){    if ( argc &gt; 1 &amp;&amp; <a name="QString"></a><a href="qstring.html">QString</a>(argv[1]) == "-m" ) {        <a name="QApplication::setColorSpec"></a><a href="qapplication.html#1ee2d1">QApplication::setColorSpec</a>( QApplication::ManyColor );        argc--;        argv++;    }     else if ( argc &gt; 1 &amp;&amp; <a href="qstring.html">QString</a>(argv[1]) == "-n" ) {        <a href="qapplication.html#1ee2d1">QApplication::setColorSpec</a>( QApplication::NormalColor );        argc--;        argv++;    }     else {        <a href="qapplication.html#1ee2d1">QApplication::setColorSpec</a>( QApplication::CustomColor );    }    <a name="QApplication::setFont"></a><a href="qapplication.html#3d926a">QApplication::setFont</a>( <a name="QFont"></a><a href="qfont.html">QFont</a>("Helvetica", 12) );    <a name="QApplication"></a><a href="qapplication.html">QApplication</a> a( argc, argv );    <a name="QFileDialog::setIconProvider"></a><a href="qfiledialog.html#8d2ecf">QFileDialog::setIconProvider</a>(new ImageIconProvider);    if ( argc &lt;= 1 ) {        // Create a window which looks after its own existence.        ImageViewer *w =            new ImageViewer(0, "new window", Qt::WDestructiveClose | Qt::WResizeNoErase );        w-&gt;<a name="setCaption"></a><a href="qwidget.html#d6a291">setCaption</a>("Qt Example - Image Viewer");        w-&gt;<a name="show"></a><a href="qwidget.html#200ee5">show</a>();    } else {        for ( int i=1; i&lt;argc; i++ ) {            // Create a window which looks after its own existence.            ImageViewer *w =                new ImageViewer(0, argv[i], Qt::WDestructiveClose | Qt::WResizeNoErase );            w-&gt;<a href="qwidget.html#d6a291">setCaption</a>("Qt Example - Image Viewer");            w-&gt;loadImage( argv[i] );            w-&gt;<a href="qwidget.html#200ee5">show</a>();        }    }    <a name="QObject::connect"></a><a href="qobject.html#7f8e37">QObject::connect</a>(qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));    return a.<a name="exec"></a><a href="qapplication.html#84c7bf">exec</a>();}</pre><p><address><hr><div align="center"><table width="100%" cellspacing="0" border="0"><tr><td>Copyright 

⌨️ 快捷键说明

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