void QSPixmapClass::resize( QSEnv *env ) { if ( env->numArgs() < 1 || env->numArgs() > 2 ) { env->throwError( QString::fromLatin1( "Pixmap.resize() called with %1 arguments. 1 or 2 arguments expected." ). arg( env->numArgs() ) ); return; } QSObject t = env->thisValue(); QSPixmapClass *pac = (QSPixmapClass*)t.objectType(); QPixmap *pix = pac->pixmap( &t ); if ( env->numArgs() == 1 ) { QSObject a0 = env->arg( 0 ); if ( !a0.isA( "Size" ) ) { env->throwError( QString::fromLatin1( "Pixmap.resize() called with an argument of type %1. " "Type Size is expeced" ). arg( a0.typeName() ) ); return; } pix->resize( *( (QSSizeClass*)a0.objectType() )->size( &a0 ) ); } else { if ( !env->arg( 0 ).isA( "Number" ) || !env->arg( 1 ).isA( "Number" ) ) { env->throwError( QString::fromLatin1( "Pixmap.resize() called with arguments of type %1 and %2. " "Type Number and Number is expeced" ). arg( env->arg( 0 ).typeName() ).arg( env->arg( 1 ).typeName() ) ); return; } pix->resize( env->arg( 0 ).toInteger(), env->arg( 1 ).toInteger() ); } return; }
void QSPixmapClass::save( QSEnv *env ) { if ( env->numArgs() < 1 || env->numArgs() > 2 ) { env->throwError( QString::fromLatin1( "Pixmap.save() called with %1 arguments. 1 or 2 argument expected." ). arg( env->numArgs() ) ); return; } QSObject t = env->thisValue(); QSPixmapClass *pac = (QSPixmapClass*)t.objectType(); QPixmap *pix = pac->pixmap( &t ); if ( !env->arg( 0 ).isString() ) { env->throwError( QString::fromLatin1( "Pixmap.save() called with an argument of type %1. " "Type String is expeced" ). arg( env->arg( 0 ).typeName() ) ); return; } QString format = QFileInfo( env->arg( 0 ).toString() ).extension().upper(); QStrList l = QImageIO::outputFormats(); if ( l.find( format.latin1() ) == -1 ) format = QString::fromLatin1("PNG"); if ( env->numArgs() == 2 ) { if ( !env->arg( 1 ).isString() ) { env->throwError( QString::fromLatin1( "Pixmap.save() called with an argument of type %1. " "as second argument. Type String is expeced" ). arg( env->arg( 1 ).typeName() ) ); return; } format = env->arg( 1 ).toString(); } pix->save( env->arg( 0 ).toString(), format.latin1() ); }
void QSPixmapClass::save( QSEnv *env ) { if ( env->numArgs() < 1 || env->numArgs() > 2 ) { env->throwError( QString::fromLatin1( "Pixmap.save() called with %1 arguments. 1 or 2 argument expected." ). arg( env->numArgs() ) ); return; } QSObject t = env->thisValue(); QSPixmapClass *pac = (QSPixmapClass*)t.objectType(); QPixmap *pix = pac->pixmap( &t ); if ( !env->arg( 0 ).isString() ) { env->throwError( QString::fromLatin1( "Pixmap.save() called with an argument of type %1. " "Type String is expeced" ). arg( env->arg( 0 ).typeName() ) ); return; } QString format = QFileInfo( env->arg( 0 ).toString() ).completeSuffix().toUpper(); QList<QByteArray> l = QImageWriter::supportedImageFormats(); if ( l.indexOf( format.toLatin1() ) == -1 ) format = QString::fromLatin1("PNG"); if ( env->numArgs() == 2 ) { if ( !env->arg( 1 ).isString() ) { env->throwError( QString::fromLatin1( "Pixmap.save() called with an argument of type %1. " "as second argument. Type String is expeced" ). arg( env->arg( 1 ).typeName() ) ); return; } format = env->arg( 1 ).toString(); } pix->save( env->arg( 0 ).toString(), format.toLatin1().constData() ); }
QSObject QSPixmapClass::isNull( QSEnv *env ) { QSObject t = env->thisValue(); QSPixmapClass *pac = (QSPixmapClass*)t.objectType(); QSObject result; QPixmap *pix = pac->pixmap( &t ); return env->createBoolean( pix->isNull() ); }
void QSPixmapClass::resize( QSEnv *env ) { if ( env->numArgs() < 1 || env->numArgs() > 2 ) { env->throwError( QString::fromLatin1( "Pixmap.resize() called with %1 arguments. 1 or 2 arguments expected." ). arg( env->numArgs() ) ); return; } QSObject t = env->thisValue(); QSPixmapClass *pac = (QSPixmapClass*)t.objectType(); QPixmap *pix = pac->pixmap( &t ); int w=-1; int h=-1; if ( env->numArgs() == 1 ) { QSObject a0 = env->arg( 0 ); if ( !a0.isA( "Size" ) ) { env->throwError( QString::fromLatin1( "Pixmap.resize() called with an argument of type %1. " "Type Size is expected" ). arg( a0.typeName() ) ); return; } QSize size = *((QSSizeClass*)a0.objectType())->size(&a0); w = size.width(); h = size.height(); } else { if ( !env->arg( 0 ).isA( "Number" ) || !env->arg( 1 ).isA( "Number" ) ) { env->throwError( QString::fromLatin1( "Pixmap.resize() called with arguments of type %1 and %2. " "Type Number and Number is expected" ). arg( env->arg( 0 ).typeName() ).arg( env->arg( 1 ).typeName() ) ); return; } w = env->arg( 0 ).toInteger(); h = env->arg( 1 ).toInteger(); } if (w >= 0 && h >= 0) { QPixmap tmppm(w, h); tmppm.fill(Qt::black); QPainter p(&tmppm); p.drawPixmap(0, 0, *pix); *pix = tmppm; } return; }
void QSPixmapClass::load( QSEnv *env ) { if ( env->numArgs() != 1 ) { env->throwError( QString::fromLatin1( "Pixmap.load() called with %1 arguments. 1 argument expected." ). arg( env->numArgs() ) ); return; } if ( !env->arg( 0 ).isString() ) { env->throwError( QString::fromLatin1( "Pixmap.load() called with an argument of type %1. " "Type String is expeced" ). arg( env->arg( 0 ).typeName() ) ); return; } QSObject t = env->thisValue(); QSPixmapClass *pac = (QSPixmapClass*)t.objectType(); QPixmap *pix = pac->pixmap( &t ); pix->load( env->arg( 0 ).toString() ); return; }
void QSPixmapClass::fill( QSEnv *env ) { if ( env->numArgs() != 1 ) { env->throwError( QString::fromLatin1( "Pixmap.fill() called with %1 arguments. 1 arguments expected." ). arg( env->numArgs() ) ); return; } QSObject a0 = env->arg( 0 ); if ( !a0.isA( "Color" ) ) { env->throwError( QString::fromLatin1( "Pixmap.fill() called with an argument of type %1. " "Type Color is expeced" ). arg( a0.typeName() ) ); return; } QSObject t = env->thisValue(); QSPixmapClass *pac = (QSPixmapClass*)t.objectType(); QPixmap *pix = pac->pixmap( &t ); pix->fill( *( (QSColorClass*)a0.objectType() )->color( &a0 ) ); return; }