i want get each pixel of a sprite, but i don't know how? Would anyone give me some clue?

CCSprite *target = CCSprite::create(“pig.png”);
i want to get each pixel of ‘target’ to manipulate, any help will be helpful.
waiting on line.

Sprite itself uses texture which loaded to videocard memory, so the only way to get pixels is to create CCImage from the same file.

You cannot and shouldn’t set image pixels anyway, but with CCImage you can get pixels array, width and height of picture.

i want to write info into pixel, such as i want change the alpha value of a pixel. But CCImage is so time consuming.

Sergey Shambir wrote:

Sprite itself uses texture which loaded to videocard memory, so the only way to get pixels is to create CCImage from the same file.
>
You cannot and shouldn’t set image pixels anyway, but with CCImage you can get pixels array, width and height of picture.

i want to write info into pixel, such as i want change the alpha value of a pixel. But CCImage is so time consuming.

Per-pixel access breaks perfomance anyway. If you want to modify color of pixels, use pixel shaders.

You should never change image dynamically because you’ll have to update image copy on videocard after each change, it’s too expensive.

Sergey Shambir wrote:

Per-pixel access breaks perfomance anyway. If you want to modify color of pixels, use pixel shaders.
>
You should never change image dynamically because you’ll have to update image copy on videocard after each change, it’s too expensive.

I’ve used CCClippingNode
void HelloWorld::setup(){
CCSize winSize = CCDirector::sharedDirector()>getWinSize;
CCSprite *target = CCSprite::create;
target
>setScaleY(winSize.height/target~~>getContentSize.height);
target~~>setScaleX(winSize.width/target~~>getContentSize.width);
target~~>setOpacity(200);

m_pOuterClipper = CCClippingNode::create();
m_pOuterClipper~~>retain;
CCAffineTransform tranform = CCAffineTransformMakeIdentity;
tranform = CCAffineTransformScale, target~~>getScaleY());
m_pOuterClipper~~>setContentSize, tranform));
m_pOuterClipper~~>setPosition(ccp(winSize.width/2,winSize.height/2));

m_pOuterClipper~~>setStencil;
holesClipper = CCClippingNode::create;
holesClipper~~>setInverted(true);
holesClipper~~>setAlphaThreshold;
holesClipper~~>addChild(target);

m_pHoles = CCNode::create();
m_pHoles~~>retain;
holesClipper~~>addChild(m_pHoles);

m_pHolesStencil = CCNode::create();
m_pHolesStencil~~>retain;
holesClipper~~>setStencil( m_pHolesStencil);

m_pOuterClipper~~>addChild;
this~~>addChild(m_pOuterClipper);
m_pOuterClipper~~>setPosition);

//m_pOuterClipper~~>ignoreAnchorPointForPosition(true);
}

when press the clipping node, this method will be called.
void HelloWorld::pokeHoleAtPoint(CCPoint point){
float scale = CCRANDOM_0_1() * 0.2 + 0.9;
float rotation = CCRANDOM_0_1() * 360;
/*
CCSprite **hole = CCSprite::create;
hole~~>setPosition;
hole~~>setRotation;
hole~~>setScale;
m_pHoles~~>addChild;
**/

CCSprite *holeStencil = CCSprite::create(“Icon-72.png”);
holeStencil~~>setPosition;
holeStencil~~>setRotation( rotation );
holeStencil~~>setScale;
m_pHolesStencil~~>addChild(holeStencil);
holeStencil~~>runAction);
//m_pHolesStencil~~>runAction(CCFadeOut::create(4));
//m_pHolesStencil~~>addChild;
//m_pOuterClipper~~>runAction(CCSequence::createWithTwoActions(CCScaleBy::create(0.05f, 0.95f),CCScaleTo::create(0.125f, 1)));
}

i want the hole play CCFadeOut , but seems it doesn’t work, the hole doesn’t disappear.

any idea how to implement it ?

still unsolved…. really need some help.