VCardLine VCardTool::createPicture(const QString &identifier, const Picture &pic) { VCardLine line(identifier); if(pic.isIntern()) { if(!pic.data().isNull()) { QByteArray input; QBuffer buffer(input); buffer.open(IO_WriteOnly); QImageIO iio(&buffer, "JPEG"); iio.setImage(pic.data()); iio.setQuality(100); iio.write(); line.setValue(input); line.addParameter("encoding", "b"); line.addParameter("type", "image/jpeg"); } } else if(!pic.url().isEmpty()) { line.setValue(pic.url()); line.addParameter("value", "URI"); } return line; }
void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) { ContentLine cl; cl.setName( EntityTypeToParamName( type ) ); if ( pic.isIntern() && pic.data().isNull() ) return; if ( !pic.isIntern() && pic.url().isEmpty() ) return; ParamList params; if ( pic.isIntern() ) { QImage img = pic.data(); if ( intern ) { // only for vCard export we really write the data inline QByteArray data; QDataStream s( data, IO_WriteOnly ); s.setVersion( 4 ); // to produce valid png files s << img; cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); } else { // save picture in cache QString dir; if ( type == EntityPhoto ) dir = "photos"; if ( type == EntityLogo ) dir = "logos"; img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() ); cl.setValue( new TextValue( "<dummy>" ) ); } params.append( new Param( "ENCODING", "b" ) ); if ( !pic.type().isEmpty() ) params.append( new Param( "TYPE", pic.type().utf8() ) ); } else { cl.setValue( new TextValue( pic.url().utf8() ) ); params.append( new Param( "VALUE", "uri" ) ); } cl.setParamList( params ); vcard->add( cl ); }
void CMonitoringUI::handle1(Poco::Notification* pNf) { poco_check_ptr(pNf); Picture *pImg = NULL; //CaptureNotify::handle1(pNf); //CaptureNotify::handle1(pNf, &pImg); Notification::Ptr pf(pNf); poco_check_ptr(pf.get()); CaptureNotification::Ptr nf = pf.cast<CaptureNotification>(); poco_check_ptr(nf.get()); Picture::Ptr pic(nf->data()); poco_check_ptr(pic.get()); pImg = pic.get(); CapBitmapData capdata((const BYTE *)pImg->data(), pImg->width() * pImg->height() * 3, pImg->width(), pImg->height()); Camera::MirrorDIB((const char *)capdata.getData(), capdata.getWidth(), capdata.getHeigth(), false, 24); m_capdata.push(capdata); //delete pImg; }
int UpdateImage(void* data) { double timeout = data != 0 ? *((double*)data) : 5; Picture pic; SDL_mutexP(srvMutex); PosixTimer pt; bool fDone = false; while (!fDone) { try { pic = srv->takePicture(); fDone = true; } catch (...) { // Are we out of time? if (timeout > 0 && pt.elapsed() > timeout) { fDone = true; } else { fDone = false; } } } SDL_mutexV(srvMutex); if (pic) { SDL_mutexP(jpegImageMutex); if (jpegImage != 0) { SDL_FreeSurface(jpegImage); } if ((jpegImage = IMG_Load_RW(SDL_RWFromConstMem(pic.data(), pic.size()), 1)) == 0) { cerr << "Failed to load image: " << SDL_GetError() << endl; } else { fUpdatedImage = true; } SDL_mutexV(jpegImageMutex); } fUpdatingImage = false; return 0; }