void KJSeeker::paint(QPainter *p, const QRect &) { closest(); QPixmap *pixmap = toPixmap(g); pixmap->setMask(barModeMask); bitBlt(p->device(), rect().topLeft().x(), rect().topLeft().y(), pixmap, 0, 0, rect().width(), rect().height(), Qt::CopyROP); }
bool Q3DGraph::save(const KURL& url) { if ( KIO::NetAccess::exists( url, false, this ) ) //The file already exist return false; QString type(KImageIO::type(url.path())); if (type.isNull()) type = "PNG"; bool ok = false; if(url.isLocalFile()) { KSaveFile saveFile(url.path()); if ( saveFile.status() == 0 ) { if (toPixmap().save( saveFile.file(), type.latin1() ) ) ok = saveFile.close(); } } else { KTempFile tmpFile; tmpFile.setAutoDelete(true); if(tmpFile.status()==0) { if(toPixmap().save( tmpFile.file(), type.latin1())) { if(tmpFile.close()) ok = KIO::NetAccess::upload( tmpFile.name(), url, this ); } } } // QApplication::restoreOverrideCursor(); if (!ok) { qDebug("Was unable to save it"); } return ok; }
void UIGSelectorItem::mouseMoveEvent(QGraphicsSceneMouseEvent *pEvent) { /* Make sure item is really dragged: */ if (QLineF(pEvent->screenPos(), pEvent->buttonDownScreenPos(Qt::LeftButton)).length() < QApplication::startDragDistance()) return; /* Initialize dragging: */ QDrag *pDrag = new QDrag(pEvent->widget()); model()->setCurrentDragObject(pDrag); pDrag->setPixmap(toPixmap()); pDrag->setMimeData(createMimeData()); pDrag->exec(Qt::MoveAction | Qt::CopyAction, Qt::MoveAction); }
QVariant QtPixmapRuntime::toQt(JSContextRef context, JSObjectRef obj, QMetaType::Type hint, JSValueRef* exception) { if (!obj) return emptyVariantForHint(hint); if (JSValueIsObjectOfClass(context, obj, QtPixmapRuntime::getClassRef())) { QVariant* originalVariant = static_cast<QVariant*>(JSObjectGetPrivate(obj)); if (hint == qMetaTypeId<QPixmap>()) return QVariant::fromValue<QPixmap>(toPixmap(*originalVariant)); if (hint == qMetaTypeId<QImage>()) return QVariant::fromValue<QImage>(toImage(*originalVariant)); } JSObject* jsObject = ::toJS(obj); if (!jsObject->inherits(&JSHTMLImageElement::s_info)) return emptyVariantForHint(hint); JSHTMLImageElement* elementJSWrapper = static_cast<JSHTMLImageElement*>(jsObject); HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(elementJSWrapper->impl()); if (!imageElement) return emptyVariantForHint(hint); CachedImage* cachedImage = imageElement->cachedImage(); if (!cachedImage) return emptyVariantForHint(hint); Image* image = cachedImage->imageForRenderer(imageElement->renderer()); if (!image) return emptyVariantForHint(hint); QImage* nativeImage = image->nativeImageForCurrentFrame(); if (!nativeImage) return emptyVariantForHint(hint); return (hint == static_cast<QMetaType::Type>(qMetaTypeId<QPixmap>())) ? QVariant::fromValue<QPixmap>(QPixmap::fromImage(*nativeImage)) : QVariant::fromValue<QImage>(*nativeImage); }
static JSValueRef assignToHTMLImageElement(JSContextRef context, JSObjectRef function, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (!argumentCount) return JSValueMakeUndefined(context); JSObjectRef objectArg = JSValueToObject(context, arguments[0], exception); if (!objectArg) return JSValueMakeUndefined(context); JSObject* jsObject = ::toJS(objectArg); if (!jsObject->inherits(&JSHTMLImageElement::s_info)) return JSValueMakeUndefined(context); QVariant& data = *static_cast<QVariant*>(JSObjectGetPrivate(object)); // We now know that we have a valid <img> element as the argument, we can attach the pixmap to it. RefPtr<StillImage> stillImage = WebCore::StillImage::create(toPixmap(data)); HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(static_cast<JSHTMLImageElement*>(jsObject)->impl()); imageElement->setCachedImage(new CachedImage(stillImage.get())); return JSValueMakeUndefined(context); }