void CanvasRenderer::paintTransformedSelection( QPainter& painter )
{
    // Make sure there is something selected
    //
    if (mSelection.width() == 0 || mSelection.height() == 0) {
        return;
    }

    Layer* layer = mObject->getLayer( mLayerIndex );

    if (layer->type() == Layer::BITMAP) {

        // Get the transformed image
        //
        BitmapImage* bitmapImage = dynamic_cast< LayerBitmap* >( layer )->getLastBitmapImageAtFrame( mFrameNumber, 0 );

        BitmapImage transformedImage = bitmapImage->transformed(mSelection, mSelectionTransform, mOptions.bAntiAlias);


        // Paint the transformation output
        //
        painter.setWorldMatrixEnabled( true );
        transformedImage.paintImage(painter);
    }
}
示例#2
0
void DockCamera::Paint( const Rect &cUpdateRect )
{
	os::Color32_s sCurrentColor = BlendColours(get_default_color(os::COL_SHINE),  get_default_color(os::COL_NORMAL_WND_BORDER), 0.5f);
	SetFgColor( Tint( get_default_color( os::COL_SHADOW ), 0.5f ) );
	os::Color32_s sBottomColor = BlendColours(get_default_color(os::COL_SHADOW), get_default_color(os::COL_NORMAL_WND_BORDER), 0.5f);
	
	os::Color32_s sColorStep = os::Color32_s( ( sCurrentColor.red-sBottomColor.red ) / 30, 
											( sCurrentColor.green-sBottomColor.green ) / 30, 
											( sCurrentColor.blue-sBottomColor.blue ) / 30, 0 );
	
	if( cUpdateRect.DoIntersect( os::Rect( 0, 0, GetBounds().right, 29 ) ) )
	{
		sCurrentColor.red -= (int)cUpdateRect.top * sColorStep.red;
		sCurrentColor.green -= (int)cUpdateRect.top * sColorStep.green;
		sCurrentColor.blue -= (int)cUpdateRect.top * sColorStep.blue;
		for( int i = (int)cUpdateRect.top; i < ( (int)cUpdateRect.bottom < 30 ? (int)cUpdateRect.bottom + 1 : 30 ); i++ )
		{
			SetFgColor( sCurrentColor );
			DrawLine( os::Point( cUpdateRect.left, i ), os::Point( cUpdateRect.right, i ) );
			sCurrentColor.red -= sColorStep.red;
			sCurrentColor.green -= sColorStep.green;
			sCurrentColor.blue -= sColorStep.blue;
		}
	}

	SetDrawingMode( os::DM_BLEND );
	if (pcPaint && !m_bHover)	
		pcPaint->Draw( Point(0,0), this );
	else
	{
		m_pcIcon->Draw(Point(0,0),this);
	}

	SetDrawingMode(DM_COPY);
}
示例#3
0
文件: editor.cpp 项目: qbdp/pencil
bool Editor::importBitmapImage( QString filePath )
{
    backup( tr( "ImportImg" ) );

    QImageReader reader( filePath );

    Q_ASSERT( layers()->currentLayer()->type() == Layer::BITMAP );
    auto layer = static_cast<LayerBitmap*>( layers()->currentLayer() );

    QImage img( reader.size(), QImage::Format_ARGB32_Premultiplied );

    while ( reader.read( &img ) )
    {
        if ( img.isNull() || reader.nextImageDelay() <= 0 )
        {
            break;
        }

        if ( !layer->keyExists( currentFrame() ) )
        {
            addNewKey();
        }
        BitmapImage* bitmapImage = layer->getBitmapImageAtFrame( currentFrame() );

        QRect boundaries = img.rect();
        boundaries.moveTopLeft( mScribbleArea->getCentralPoint().toPoint() - QPoint( boundaries.width() / 2, boundaries.height() / 2 ) );

        BitmapImage* importedBitmapImage = new BitmapImage( boundaries, img );
        bitmapImage->paste( importedBitmapImage );

        scrubTo( currentFrame() + 1 );
    }

    return true;
}
示例#4
0
void LoadImageForTest( const std::string& image_filepath )
{
	LOG_SCOPE( image_filepath.c_str() );

	BitmapImage img;
	img.LoadFromFile( image_filepath );
}
示例#5
0
void Editor::copy()
{
    Layer* layer = mObject->getLayer(layers()->currentLayerIndex());
    if (layer == nullptr)
    {
        return;
    }

    if (layer->type() == Layer::BITMAP)
    {
        LayerBitmap* layerBitmap = static_cast<LayerBitmap*>(layer);
        if (mScribbleArea->isSomethingSelected())
        {
            g_clipboardBitmapImage = layerBitmap->getLastBitmapImageAtFrame(currentFrame(), 0)->copy(mScribbleArea->getSelection().toRect());  // copy part of the image
        }
        else
        {
            g_clipboardBitmapImage = layerBitmap->getLastBitmapImageAtFrame(currentFrame(), 0)->copy();  // copy the whole image
        }
        clipboardBitmapOk = true;
        if (g_clipboardBitmapImage.image() != nullptr)
            QApplication::clipboard()->setImage(*g_clipboardBitmapImage.image());
    }
    if (layer->type() == Layer::VECTOR)
    {
        clipboardVectorOk = true;
        g_clipboardVectorImage = *((static_cast<LayerVector*>(layer))->getLastVectorImageAtFrame(currentFrame(), 0));  // copy the image
    }
}
示例#6
0
void applyFloydSteinberg(){
    string path;

    DIR* directory;

    struct dirent *ep;

    list<string> gabaritos;

    cout << "Entre com o caminho com as imagens que se deseja aplicar o dithering: ";
    getline(cin, path);

    directory = opendir(path.c_str());

    if(directory == NULL){
        cerr << "Error(" << errno << ") opening " << directory << endl;
        return;
    }
    while((ep = readdir(directory))){
        auto filePath = path + "/" + ep->d_name;
        if(has_suffix(filePath, ".bmp")){
            cout << filePath << endl;
            gabaritos.push_back(filePath);
        }

    }
    for(auto it = gabaritos.begin(); it != gabaritos.end(); it++){
        string aux="";
        aux+= *it;
        string aux2="";
        BitmapImage teste = BitmapImage(aux, find_file_name((*it)));
        teste.floydSteinberg();
    }
    return;
}
示例#7
0
void
BitmapImage::downloader_failed (EventObject *sender, EventArgs *calldata, gpointer closure)
{
	BitmapImage *media = (BitmapImage *) closure;
	
	media->DownloaderFailed ();
}
示例#8
0
void
BitmapImage::downloader_complete (EventObject *sender, EventArgs *calldata, gpointer closure)
{
	BitmapImage *media = (BitmapImage *) closure;

	media->DownloaderComplete ();
}
示例#9
0
void
BitmapImage::downloader_progress_changed (EventObject *sender, EventArgs *calldata, gpointer closure)
{
	BitmapImage *media = (BitmapImage *) closure;

	media->DownloaderProgressChanged ();
}
示例#10
0
void EyedropperTool::mouseReleaseEvent(QMouseEvent *event)
{
    Layer* layer = mEditor->layers()->currentLayer();
    if (layer == NULL) { return; }

    if (event->button() == Qt::LeftButton)
    {
        if (layer->type() == Layer::BITMAP)
        {
            BitmapImage* targetImage = ((LayerBitmap *)layer)->getLastBitmapImageAtFrame( mEditor->currentFrame(), 0);
            //QColor pickedColour = targetImage->pixel(getLastPoint().x(), getLastPoint().y());
            QColor pickedColour;
            pickedColour.setRgba( targetImage->pixel( getLastPoint().x(), getLastPoint().y() ) );
            int transp = 255 - pickedColour.alpha();
            pickedColour.setRed( pickedColour.red() + transp );
            pickedColour.setGreen( pickedColour.green() + transp );
            pickedColour.setBlue( pickedColour.blue() + transp );
            if (pickedColour.alpha() != 0)
            {
                mEditor->color()->setColor(pickedColour);
            }
        }
        else if (layer->type() == Layer::VECTOR)
        {
            VectorImage *vectorImage = ((LayerVector *)layer)->getLastVectorImageAtFrame(mEditor->currentFrame(), 0);
            int colourNumber = vectorImage->getColourNumber(getLastPoint());
            if (colourNumber != -1)
            {
                mEditor->color()->setColorNumber(colourNumber);
            }
        }
    }
}
示例#11
0
static void loadTextureImage() {
	BitmapImage * image = NULL;
	
	if (texture != NULL) {
		texture->dispose(texture);
		texture = NULL;
	}
	
	if (jsonPath != NULL) {
		JSONDeserializationContext * context;
		
		context = JSONDeserializationContext_createWithFile(jsonPath);
		texture = GLTexture_deserialize(context);
		if (texture == NULL) {
			fprintf(stderr, "Error: Couldn't load %s as gltexture.json file: %d\n", jsonPath, context->status);
			
		} else {
			char imagePath[PATH_MAX];
			
			if (jsonImagePath == NULL) {
				size_t charIndex;
				
				strncpy(imagePath, jsonPath, PATH_MAX);
				for (charIndex = strlen(imagePath) - 1; charIndex > 0; charIndex--) {
					if (imagePath[charIndex] == '/') {
						charIndex++;
						break;
					}
				}
				strncpy(imagePath + charIndex, texture->imageName, PATH_MAX - charIndex);
				
			} else {
				snprintf(imagePath, PATH_MAX, "%s/%s", jsonImagePath, texture->imageName);
			}
			image = PNGImageIO_loadPNGFile(imagePath, PNG_PIXEL_FORMAT_AUTOMATIC, true);
			if (image == NULL) {
				fprintf(stderr, "Error: Couldn't load %s as gltexture.json file\n", imagePath);
				texture->dispose(texture);
				texture = NULL;
			}
		}
	}
	
	if (texture == NULL) {
		image = PNGImageIO_loadPNGFile(resourcePath(textureImages[textureIndex].fileName), PNG_PIXEL_FORMAT_AUTOMATIC, true);
		texture = GLTexture_create(textureImages[textureIndex].dataFormat,
		                           GL_UNSIGNED_BYTE,
		                           minFilters[minFilterIndex],
		                           magFilters[magFilterIndex],
		                           wrapModes[wrapSModeIndex],
		                           wrapModes[wrapTModeIndex],
		                           autoBlendModes[autoBlendModeIndex],
		                           autoMipmap,
		                           anisotropicFilter);
	}
	
	texture->setImage(texture, 0, image->width, image->height, image->bytesPerRow, image->pixels);
	image->dispose(image);
}
示例#12
0
文件: media.cpp 项目: snorp/moon
void
Image::DownloadProgress ()
{
	BitmapImage *source = (BitmapImage *) GetSource ();

	SetDownloadProgress (source->GetProgress ());
	Emit (DownloadProgressChangedEvent);
}
示例#13
0
BitmapImage* MainWindow::LoadImageFromResource( String zResource )
{
	BitmapImage *pcImage = new BitmapImage();
	Resources cRes( get_image_id() );
	ResStream *pcStream = cRes.GetResourceStream( zResource );
	pcImage->Load( pcStream );
	delete ( pcStream );
	return pcImage;
}
示例#14
0
文件: icon.cpp 项目: PyroOS/Pyro
void Icon::Paint( const Rect &cUpdateRect )
{
	EraseRect( cUpdateRect );

	if( m_bSelected )
	{
		Rect cUpdateFrame = GetBounds();
		cUpdateFrame.top += 2;
		cUpdateFrame.left += 2;

		/* XXXKV: This is a hack; why is the height from GetBounds() so large? */
		cUpdateFrame.right = m_cSize.x - 2;
		cUpdateFrame.bottom = m_cSize.y - 2;

		FillRect( cUpdateFrame, m_sHighlightColor );

		/* Round edges */
		SetDrawingMode( DM_COPY );
		SetFgColor( m_sHighlightColor );

		DrawLine( os::Point( cUpdateFrame.left + 2, cUpdateFrame.top - 2 ), 
					os::Point( cUpdateFrame.right - 2, cUpdateFrame.top - 2 ) );
		DrawLine( os::Point( cUpdateFrame.left, cUpdateFrame.top - 1 ), 
					os::Point( cUpdateFrame.right, cUpdateFrame.top - 1 ) );
			
		DrawLine( os::Point( cUpdateFrame.left - 2, cUpdateFrame.top + 2 ), 
					os::Point( cUpdateFrame.left - 2, cUpdateFrame.bottom - 2 ) );
		DrawLine( os::Point( cUpdateFrame.left - 1, cUpdateFrame.top ), 
					os::Point( cUpdateFrame.left - 1, cUpdateFrame.bottom ) );
								
		DrawLine( os::Point( cUpdateFrame.left + 2, cUpdateFrame.bottom + 2 ), 
					os::Point( cUpdateFrame.right - 2, cUpdateFrame.bottom + 2 ) );
		DrawLine( os::Point( cUpdateFrame.left, cUpdateFrame.bottom + 1 ), 
					os::Point( cUpdateFrame.right, cUpdateFrame.bottom + 1 ) );
								
		DrawLine( os::Point( cUpdateFrame.right + 2, cUpdateFrame.top + 2 ), 
						os::Point( cUpdateFrame.right + 2, cUpdateFrame.bottom - 2 ) );
		DrawLine( os::Point( cUpdateFrame.right + 1, cUpdateFrame.top ), 
					os::Point( cUpdateFrame.right + 1, cUpdateFrame.bottom ) );

		SetFgColor( m_sFgColor );
	}

	SetDrawingMode( DM_BLEND );

	/* XXXKV: Will only work with BitmapImage; should use RTTI to find
	   type and handle accordingly */
	BitmapImage *pcImage = static_cast<BitmapImage*>( m_pcImage );
	Bitmap *pcBitmap = pcImage->LockBitmap();
	DrawBitmap( pcBitmap, pcImage->GetBounds(), m_cImageFrame );
	pcImage->UnlockBitmap();

	/* Draw the icon name */
	SetDrawingMode( DM_OVER );
	MovePenTo( m_cNamePos );
	DrawString( m_cName );
}
bool Editor::importBitmapImage( QString filePath )
{
    backup( tr( "ImportImg" ) );
    qDebug(filePath.toLatin1().data());
    QImageReader reader( filePath );

    Q_ASSERT( layers()->currentLayer()->type() == Layer::BITMAP );
    auto layer = static_cast<LayerBitmap*>( layers()->currentLayer() );

    QImage img;//( reader.size(), QImage::Format_ARGB32_Premultiplied );
    img.load(filePath);
    while ( reader.read( &img ) )
    {/*
        if ( img.isNull() || reader.nextImageDelay() <= 0 )
        {
            qDebug("why not image");
            break;
        }*/

        if ( !layer->keyExists( currentFrame() ) )
        {
            qDebug("why not imagesadfsdaf ssd");
            addNewKey();
        }


        BitmapImage* bitmapImage = layer->getBitmapImageAtFrame( currentFrame() );

        QRect boundaries = img.rect();

        boundaries.moveTopLeft( mScribbleArea->getCentralPoint().toPoint() - QPoint( boundaries.width() / 2, boundaries.height() / 2 ) );
        BitmapImage* importedBitmapImage = new BitmapImage( boundaries, img );
        bitmapImage->paste( importedBitmapImage );

      if(layers()->currentLayerIndex()>2)
      {
        //下面用来框出倒入的图片
        mScribbleArea->mySelection.moveTopLeft(mScribbleArea->getCentralPoint().toPoint() - QPoint( boundaries.width()/1.5, boundaries.height()/1.5) );//这个是为了将值赋给QRectF
        mScribbleArea->mySelection.moveBottomRight(mScribbleArea->getCentralPoint().toPoint() + QPoint( boundaries.width()/1.5, boundaries.height()/1.5));
        mScribbleArea->mySelection.setTopLeft(mScribbleArea->getCentralPoint().toPoint() - QPoint( boundaries.width()/1.5, boundaries.height()/1.5));
        mScribbleArea->mySelection.setBottomRight(mScribbleArea->getCentralPoint().toPoint() + QPoint( boundaries.width()/1.5, boundaries.height()/1.5));
        //mScribbleArea->mySelection.moveBottomRight(QPoint( boundaries.width()/2, boundaries.height()/2));
        mScribbleArea->setSelection( mScribbleArea->mySelection, true );
        mScribbleArea->myTransformedSelection = mScribbleArea->mySelection.adjusted( 0, 0, 0, 0 );
        mScribbleArea->myTempTransformedSelection = mScribbleArea->mySelection.adjusted( 0, 0, 0, 0 );
        mScribbleArea->update();
        mScribbleArea->mIncludeImg[mLayerManager->currentLayerIndex()]=mScribbleArea->mySelection;
        tools()->setCurrentTool(MOVE);
       }
       // scrubTo( currentFrame() + 1 );
    }

    return true;
}
示例#16
0
static void
resource_notify (NotifyType type, gint64 args, gpointer user_data)
{
	BitmapImage *media = (BitmapImage *) user_data;
	
	if (type == NotifyProgressChanged)
		media->SetProgress ((double)(args)/100.0);
	else if (type == NotifyFailed)
		media->DownloaderFailed ();
	else if (type == NotifyCompleted)
		media->DownloaderComplete ();
}
示例#17
0
文件: editor.cpp 项目: qbdp/pencil
void Editor::backup( int backupLayer, int backupFrame, QString undoText )
{
    while ( mBackupList.size() - 1 > mBackupIndex && mBackupList.size() > 0 )
    {
        delete mBackupList.takeLast();
    }
    while ( mBackupList.size() > 19 )   // we authorize only 20 levels of cancellation
    {
        delete mBackupList.takeFirst();
        mBackupIndex--;
    }
    Layer* layer = mObject->getLayer( backupLayer );
    if ( layer != NULL )
    {
        if ( layer->type() == Layer::BITMAP )
        {
            BackupBitmapElement* element = new BackupBitmapElement();
            element->layer = backupLayer;
            element->frame = backupFrame;
            element->undoText = undoText;
            element->somethingSelected = this->getScribbleArea()->somethingSelected;
            element->mySelection = this->getScribbleArea()->mySelection;
            element->myTransformedSelection = this->getScribbleArea()->myTransformedSelection;
            element->myTempTransformedSelection = this->getScribbleArea()->myTempTransformedSelection;
            BitmapImage* bitmapImage = ( ( LayerBitmap* )layer )->getLastBitmapImageAtFrame( backupFrame, 0 );
            if ( bitmapImage != NULL )
            {
                element->bitmapImage = bitmapImage->copy();  // copy the image
                mBackupList.append( element );
                mBackupIndex++;
            }
        }
        if ( layer->type() == Layer::VECTOR )
        {
            BackupVectorElement* element = new BackupVectorElement();
            element->layer = backupLayer;
            element->frame = backupFrame;
            element->undoText = undoText;
            element->somethingSelected = this->getScribbleArea()->somethingSelected;
            element->mySelection = this->getScribbleArea()->mySelection;
            element->myTransformedSelection = this->getScribbleArea()->myTransformedSelection;
            element->myTempTransformedSelection = this->getScribbleArea()->myTempTransformedSelection;
            VectorImage* vectorImage = ( ( LayerVector* )layer )->getLastVectorImageAtFrame( backupFrame, 0 );
            if ( vectorImage != NULL )
            {
                element->vectorImage = *vectorImage;  // copy the image (that works but I should also provide a copy() method)
                mBackupList.append( element );
                mBackupIndex++;
            }
        }
    }
}
示例#18
0
文件: editor.cpp 项目: qbdp/pencil
void Editor::clipboardChanged()
{
    if ( clipboardBitmapOk == false )
    {
        g_clipboardBitmapImage.setImage( new QImage( QApplication::clipboard()->image() ) );
        g_clipboardBitmapImage.bounds() = QRect( g_clipboardBitmapImage.topLeft(), g_clipboardBitmapImage.image()->size() );
        qDebug() << "New clipboard image" << g_clipboardBitmapImage.image()->size();
    }
    else
    {
        clipboardBitmapOk = false;
        qDebug() << "The image has been saved in the clipboard";
    }
}
示例#19
0
void CameraDelayedLooper::TimerTick(int nID)
{
	
	if (nID == CAMERA_ID)
	{
		DateTime pcTime = DateTime::Now();
		
		BitmapImage* pcBitmapImage;
		BitmapImage* pcSaveImage;
		os::String cScreenShotPath;
		os::Desktop m_Screen;
	
	
		pcSaveImage = new os::BitmapImage( Bitmap::SHARE_FRAMEBUFFER | Bitmap::ACCEPT_VIEWS );
		pcSaveImage->SetColorSpace( CS_RGBA32 );
		pcSaveImage->ResizeCanvas( os::Point( m_Screen.GetResolution() ) );
		
		
		pcBitmapImage = new os::BitmapImage((uint8*)m_Screen.GetFrameBuffer(),m_Screen.GetResolution(),m_Screen.GetColorSpace());
		pcBitmapImage->Draw( os::Point( 0, 0 ), pcSaveImage->GetView() );
		pcSaveImage->Sync();
	
		cScreenShotPath = os::String().Format("%s/Pictures/Screenshot-%d-%d-%d-%d_%d_%d.png",getenv("HOME"),pcTime.GetYear(),pcTime.GetMonth(),pcTime.GetDay(),pcTime.GetHour(),pcTime.GetMin(),pcTime.GetSec());
		File vNewFile = os::File(cScreenShotPath,O_CREAT | O_TRUNC | O_WRONLY);
		vNewFile.WriteAttr("os::MimeType", O_TRUNC, ATTR_TYPE_STRING,"image/png", 0,10 );
		pcSaveImage->Save(&vNewFile,"image/png");
		vNewFile.Flush();
		
		delete( pcSaveImage );
		delete pcBitmapImage;
		RemoveTimer(this,nID);
	}
}
示例#20
0
void
BitmapImage::pixbuf_write (EventObject *sender, EventArgs *calldata, gpointer data)
{
	BitmapImage *source = (BitmapImage *) data;
	HttpRequestWriteEventArgs *ea = (HttpRequestWriteEventArgs *) calldata;

	source->PixbufWrite ((unsigned char *) ea->GetData (), ea->GetOffset (), ea->GetCount ());
	if (source->moon_error) {
		ImageErrorEventArgs *args = NULL;
		if (source->HasHandlers(ImageFailedEvent))
			args = new ImageErrorEventArgs (*source->moon_error);
		source->CleanupLoader ();
		if (args)
			source->Emit (ImageFailedEvent, args);
	}
}
示例#21
0
文件: editor.cpp 项目: qbdp/pencil
void Editor::copy()
{
    Layer* layer = mObject->getLayer( layers()->currentLayerIndex() );
    if ( layer != NULL )
    {
        if ( layer->type() == Layer::BITMAP )
        {
            if ( mScribbleArea->somethingSelected )
            {
                g_clipboardBitmapImage = ( ( LayerBitmap* )layer )->getLastBitmapImageAtFrame( currentFrame(), 0 )->copy( mScribbleArea->getSelection().toRect() );  // copy part of the image
            }
            else
            {
                g_clipboardBitmapImage = ( ( LayerBitmap* )layer )->getLastBitmapImageAtFrame( currentFrame(), 0 )->copy();  // copy the whole image
            }
            clipboardBitmapOk = true;
            if ( g_clipboardBitmapImage.image() != NULL ) QApplication::clipboard()->setImage( *g_clipboardBitmapImage.image() );
        }
        if ( layer->type() == Layer::VECTOR )
        {
            clipboardVectorOk = true;
            g_clipboardVectorImage = *( ( ( LayerVector* )layer )->getLastVectorImageAtFrame( currentFrame(), 0 ) );  // copy the image
        }
    }
}
示例#22
0
int TestImageArchive()
{
	ImageArchive img_archive( "./images/src.bmp" );

	if( !img_archive.IsValid() )
		return -1;

	BitmapImage img;
	LoadBitmapImageFromImageArchive( img_archive, img );

	bool saved = img.SaveToFile( "./images/dest.jpg" );
	if( saved )
		return 0;
	else
		return -1;
}
示例#23
0
    void Render(const Vect2 &pos, const Vect2 &size)
    {
        Texture *texture = bitmapImage.GetTexture();

        if(texture)
        {
            if(bUseColorKey)
            {
                Shader *lastPixelShader = GetCurrentPixelShader();
                DWORD alpha = ((opacity*255/100)&0xFF);
                DWORD outputColor = (alpha << 24) | color&0xFFFFFF;
                LoadPixelShader(colorKeyShader);

                float fSimilarity = float(keySimilarity)*0.01f;
                float fBlend      = float(keyBlend)*0.01f;

                colorKeyShader->SetColor(colorKeyShader->GetParameter(2), keyColor);
                colorKeyShader->SetFloat(colorKeyShader->GetParameter(3), fSimilarity);
                colorKeyShader->SetFloat(colorKeyShader->GetParameter(4), fBlend);

                DrawSprite(texture, outputColor, pos.x, pos.y, pos.x+size.x, pos.y+size.y);
                LoadPixelShader(lastPixelShader);
            }
            else
            {
                DWORD alpha = ((opacity*255/100)&0xFF);
                DWORD outputColor = (alpha << 24) | color&0xFFFFFF;
                DrawSprite(texture, outputColor, pos.x, pos.y, pos.x+size.x, pos.y+size.y);
            }
        }
    }
示例#24
0
void EyedropperTool::mouseMoveEvent(QMouseEvent *event)
{
    Q_UNUSED(event);

    Layer* layer = mEditor->layers()->currentLayer();
    if (layer == NULL) { return; }

    if (layer->type() == Layer::BITMAP)
    {
        BitmapImage *targetImage = ((LayerBitmap *)layer)->getLastBitmapImageAtFrame(mEditor->currentFrame(), 0);
        if (targetImage->contains(getCurrentPoint()))
        {
            QColor pickedColour;
            //pickedColour.setRgba(targetImage->pixel(getCurrentPoint().x(), getCurrentPoint().y()));
            pickedColour.setRgba( targetImage->pixel( getCurrentPoint().x(), getCurrentPoint().y() ) );
            int transp = 255 - pickedColour.alpha();
            pickedColour.setRed( pickedColour.red() + transp );
            pickedColour.setGreen( pickedColour.green() + transp );
            pickedColour.setBlue( pickedColour.blue() + transp );
            if (pickedColour.alpha() != 0)
            {
                mScribbleArea->setCursor(cursor(pickedColour));
            }
            else
            {
                mScribbleArea->setCursor(cursor());
            }
        }
        else
        {
            mScribbleArea->setCursor(cursor());
        }
    }
    if (layer->type() == Layer::VECTOR)
    {
        VectorImage *vectorImage = ((LayerVector *)layer)->getLastVectorImageAtFrame(mEditor->currentFrame(), 0);
        int colourNumber = vectorImage->getColourNumber(getCurrentPoint());
        if (colourNumber != -1)
        {
            mScribbleArea->setCursor(cursor(mEditor->object()->getColour(colourNumber).colour));
        }
        else
        {
            mScribbleArea->setCursor(cursor());
        }
    }
}
示例#25
0
PassOwnPtr<DragImage> DragImage::create(Image* image, RespectImageOrientationEnum shouldRespectImageOrientation, float deviceScaleFactor)
{
    if (!image)
        return nullptr;

    RefPtr<NativeImageSkia> bitmap = image->nativeImageForCurrentFrame();
    if (!bitmap)
        return nullptr;

    if (image->isBitmapImage()) {
        ImageOrientation orientation = DefaultImageOrientation;
        BitmapImage* bitmapImage = toBitmapImage(image);
        IntSize sizeRespectingOrientation = bitmapImage->sizeRespectingOrientation();

        if (shouldRespectImageOrientation == RespectImageOrientation)
            orientation = bitmapImage->currentFrameOrientation();

        if (orientation != DefaultImageOrientation) {
            FloatRect destRect(FloatPoint(), sizeRespectingOrientation);
            if (orientation.usesWidthAsHeight())
                destRect = destRect.transposedRect();

            SkBitmap skBitmap;
            skBitmap.setConfig(
                SkBitmap::kARGB_8888_Config, sizeRespectingOrientation.width(), sizeRespectingOrientation.height());
            if (!skBitmap.allocPixels())
                return nullptr;

            SkCanvas canvas(skBitmap);
            canvas.concat(affineTransformToSkMatrix(orientation.transformFromDefault(sizeRespectingOrientation)));
            canvas.drawBitmapRect(bitmap->bitmap(), 0, destRect);

            return adoptPtr(new DragImage(skBitmap, deviceScaleFactor));
        }
    }

    SkBitmap skBitmap;
#if defined(SBROWSER_GPU_RASTERIZATION_ENABLE)
    if (!bitmap->bitmap().copyTo(&skBitmap, kPMColor_SkColorType))
#else
    if (!bitmap->bitmap().copyTo(&skBitmap, SkBitmap::kARGB_8888_Config))
#endif
        return nullptr;
    return adoptPtr(new DragImage(skBitmap, deviceScaleFactor));
}
// Create bitmap image
BitmapImage CreateBitmapImage()
{
  BitmapImage image = BitmapImage::New(4,4,Pixel::RGBA8888);

  PixelBuffer* pixbuf = image.GetBuffer();

  // Using a 4x4 image gives a better blend with the GL implementation
  // than a 3x3 image
  for(size_t i=0; i<16; i++)
  {
    pixbuf[i*4+0] = 0xFF;
    pixbuf[i*4+1] = 0xFF;
    pixbuf[i*4+2] = 0xFF;
    pixbuf[i*4+3] = 0xFF;
  }

  return image;
}
示例#27
0
文件: media.cpp 项目: snorp/moon
void
Image::SetSourceInternal (Downloader *downloader, char *PartName)
{
	// The default value for SourceProperty is NULL, so we need
	// to create one here if required.
	BitmapImage *source = (BitmapImage *) GetSource ();
	if (!source) {
		source = MoonUnmanagedFactory::CreateBitmapImage ();
		SetSource (source);
	}
	MediaBase::SetSourceInternal (downloader, PartName);

	source->AddHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
	source->AddHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
	source->AddHandler (BitmapImage::ImageFailedEvent, image_failed, this);

	source->SetDownloader (downloader, NULL, PartName);
}
示例#28
0
BitmapImage BitmapImage::transformed(QRect selection, QTransform transform, bool smoothTransform)
{
    Q_ASSERT(!selection.isEmpty());

    BitmapImage selectedPart = copy(selection);

    // Get the transformed image
    QImage transformedImage;
    if (smoothTransform)
    {
        transformedImage = selectedPart.image()->transformed(transform, Qt::SmoothTransformation);
    }
    else
    {
        transformedImage = selectedPart.image()->transformed(transform);
    }
    return BitmapImage(transform.mapRect(selection).normalized().topLeft(), transformedImage);
}
示例#29
0
TailWin::TailWin(const Rect & r, const String & file, uint32 desktopmask)
	:Window(r, "TailWin", os::String("Monitor: ") + file, 0, desktopmask)
{
	Rect bounds = GetBounds();

	m_TextView = new TailView(bounds, "tv", "", CF_FOLLOW_ALL, /*WID_FULL_UPDATE_ON_RESIZE|*/WID_WILL_DRAW);
	
	m_TextView->SetMultiLine(true);
	m_TextView->SetReadOnly(true);
	m_TextView->MakeFocus(true);

	AddShortcut( ShortcutKey(STR_POPUPMENU_COPY_SH), new Message(ID_COPY) );
	AddShortcut( ShortcutKey(STR_POPUPMENU_CLEAR_SH), new Message(ID_CLEAR) );
	AddShortcut( ShortcutKey(STR_POPUPMENU_SAVE_SH), new Message(ID_SAVE) );
	AddShortcut( ShortcutKey(STR_POPUPMENU_ABOUT_SH), new Message(ID_ABOUT) );
	AddShortcut( ShortcutKey(STR_POPUPMENU_QUIT_SH), new Message(ID_QUIT) );

	/*Font* pcAppFont = new Font;
	pcAppFont->SetFamilyAndStyle("Lucida Sans Typewriter", "Regular");
	pcAppFont->SetSize(8);

	m_TextView->SetFont(pcAppFont);
	pcAppFont->Release();
	*/
	AddChild(m_TextView);

		/* Set the application icon */
	Resources cRes( get_image_id() );
	BitmapImage	*pcAppIcon = new BitmapImage();
	pcAppIcon->Load( cRes.GetResourceStream( "icon48x48.png" ) );
	SetIcon( pcAppIcon->LockBitmap() );
	delete( pcAppIcon );
	
	m_FileName = new String(file);
	m_LastSize = -1;

	Tail();

	AddTimer(this, 10, 1000000, false);
	// Tried using NodeMonitor, but it doesn't trigger until the file
	// is closed/opened or touched somehow. Just keeping it open and
	// writing doesn't trigger the node monitor, and most log files
	// are handled just like that...
}
void Editor::paste()
{
    if((cutFlag||copyFlag)&&layers()->currentLayerIndex()>2)
    {
        newBitmapLayer();
    }
    Layer* layer = mObject->getLayer( layers()->currentLayerIndex() );
    if ( layer != NULL )
    {
        if ( layer->type() == Layer::BITMAP && g_clipboardBitmapImage.image() != NULL )
        {
            backup( tr( "Paste" ) );
            BitmapImage tobePasted = g_clipboardBitmapImage.copy();
            qDebug() << "to be pasted --->" << tobePasted.image()->size();
            if ( mScribbleArea->somethingSelected )
            {
                QRectF selection = mScribbleArea->getSelection();
                if ( g_clipboardBitmapImage.width() <= selection.width() && g_clipboardBitmapImage.height() <= selection.height() )
                {
                    tobePasted.moveTopLeft( selection.topLeft() );
                }
                else
                {
                    tobePasted.transform( selection, true );
                }
            }
            auto pLayerBitmap = static_cast< LayerBitmap* >( layer );
            pLayerBitmap->getLastBitmapImageAtFrame( currentFrame(), 0 )->paste( &tobePasted ); // paste the clipboard
        }
        else if ( layer->type() == Layer::VECTOR && clipboardVectorOk )
        {
            backup( tr( "Paste" ) );
            mScribbleArea->deselectAll();
            VectorImage* vectorImage = ( ( LayerVector* )layer )->getLastVectorImageAtFrame( currentFrame(), 0 );
            vectorImage->paste( g_clipboardVectorImage );  // paste the clipboard
            mScribbleArea->setSelection( vectorImage->getSelectionRect(), true );
            //((LayerVector*)layer)->getLastVectorImageAtFrame(backupFrame, 0)->modification(); ????
        }
    }
    mScribbleArea->updateCurrentFrame();
    if((cutFlag&&!mScribbleArea->somethingSelected)||(copyFlag&&mScribbleArea->somethingSelected))
    {
        mScribbleArea->mySelection=cutArea;
        mScribbleArea->setSelection( mScribbleArea->mySelection, true );
        mScribbleArea->myTransformedSelection = mScribbleArea->mySelection.adjusted( 0, 0, 0, 0 );
        mScribbleArea->myTempTransformedSelection = mScribbleArea->mySelection.adjusted( 0, 0, 0, 0 );
        mScribbleArea->update();
        mScribbleArea->mIncludeImg[mLayerManager->currentLayerIndex()]=mScribbleArea->mySelection;
        tools()->setCurrentTool(MOVE);
    }
    cutFlag =0;
    copyFlag =0;
}