Hi all. I’m using e new function captureScreen for take a screen shot and save it into file.
http://www.cocos2d-x.org/wiki/How_to_Save_a_Screenshot
I have a problem for this. How can i change orientation image (meta data or execute rotations)? Thank you
I don’t know of a built in way to do this (http://www.cocos2d-x.org/reference/native-cpp/V3.2/d0/d1e/namespacecocos2d_1_1utils.html )
You could probably use libpng to do this, although I haven’t checked. Maybe also, since you can get a Sprite
from the RenderTexture
you could rotate it using setRotation()
. I’m just talking out loud.
in this way when i use RenderTexture->saveToFile not always save the last screen and it not rewrite newest files.
in utils captureScreen, save screen in this way:
std::shared_ptr<GLubyte> buffer(new GLubyte[width * height * 4], [](GLubyte* p) {CC_SAFE_DELETE_ARRAY(p);});
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, h / 8, width,height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.get());
then flip the image correctly:
std::shared_ptr<GLubyte> flippedBuffer(new GLubyte[width * height * 4], [](GLubyte* p) {CC_SAFE_DELETE_ARRAY(p);});
for (int row = 0; row < height; ++row)
{
memcpy(flippedBuffer.get() + (height - row - 1) * width * 4, buffer.get() + row * width * 4, width * 4);
}
then save buffer in image type:
std::shared_ptr<Image> image(new Image);
image->initWithRawData(flippedBuffer.get(), width * height * 4, width, height, 8);
image->saveToFile(outputFile);
is there a way for rotate the image? in this method screenshot are always saved perfect without bugs. Thanks
I think that this has been fixed in GitHub if you pull from that.
cocos2d-x-3.16 Oct.9 2017
[NEW] Add RadialGradientLayer
[NEW] Web: Add GLProgramState and upgrade web shader usage APIs
[REFINE] 3rd: use prebuilt bullet
[REFINE] CameraBackgroundBrush: use VAO/VBO to improve performance
[REFINE] Color4F: add arithmentic operators
[REFINE] LayerMultiplex: add `LayerMultiplex::switch(int, bool)` to not clean up previous layer after switching to a new layer
[REFINE] ListView: add padding options
[REFINE] FileUtils: add more async functions
[REFINE] ImageView: add `ImageView::setBlendFunc()` to change blend function
[REFINE] PageView: allow customizing opacity of indicator nodes
[REFINE] ParticleSystem: add `ParticleSystem::setSourcePositionCompatible(bool)` to set source position instead of position
[REFINE] RichText: image tag supports sprite frame
[REFINE] RichText: support horizontal alignment
[REFINE] ScrollView: add `ScrollView::setSwallowTouches(bool)`
[REFINE] ScrollView: dispatch more useful events and add more getters
[REFINE] Spine: support ETC1
[REFINE] WebView: can set opacity
[REFINE] Android: update to support Android Studio 2.3.3
This file has been truncated. show original
3.3 is a beta version? how can i update my version in cmd? i’ve installed cocos with phyton and for create new project i use command:
cocos new project -p package -l cpp
is it correct?
you would need to clone from GitHub
and then run ./download-deps.py
. Then you can simply do git pull origin
to always bring down the latest and be up to date. It is the development branch.
slackmoehrle:
./download-deps.py
what is his functionality? thank you…