Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A example : Take a screenshot & Share the screenshot #23

Open
finscn opened this issue Sep 7, 2015 · 40 comments
Open

A example : Take a screenshot & Share the screenshot #23

finscn opened this issue Sep 7, 2015 · 40 comments

Comments

@finscn
Copy link
Owner

finscn commented Sep 7, 2015

All code in index.js of this example:


//=======================================
// Initialize the screen canvas
//=======================================
var width = window.innerWidth;
var height = window.innerHeight;
var canvas = document.getElementById('canvas');
canvas.width = width;
canvas.height = height;
canvas.retinaResolutionEnabled = true;
var context = canvas.getContext("2d");
context.fillStyle = "#000000";
context.fillRect(0, 0, width, height);


//=======================================
// Draw something on screen canvas
//=======================================
context.fillStyle = "#ff6600";
context.font = "60px Arial";
context.fillText("Test", 30, 100);
context.fillRect(0, height >> 1, width, 20);
context.fillRect(width >> 1, 0, 20, height);


//=======================================
// Take a screenshot.
//=======================================
var appUtils = new Ejecta.AppUtils();
// In fact, saveImage() is a synchronous method.
// You could also use a offscreen canvas that you created via document.createElement().
appUtils.saveImage(canvas, "${Documents}/test.png", function(filePath) {
    console.log(filePath);
});


//=======================================
// Share the screenshot that you took.
//=======================================
var social = new Ejecta.Social();
// Why setTimeout :
// You can't open social dialog as soon as app starts
// You must wait a moment for initialization of SocialSDK
setTimeout(function() {
    social.showPostDialog('twitter', 'test message', "http://google.com", '${Documents}/test.png');
}, 1200);


@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

@matrixreal , I'v tried the best of my ability for helping you.

@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

@matrixreal , there is a full example phoboslab#540

and Could you Star my fork version of Ejecta ?

@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

@matrixreal , you asked :

can i take screen shoot and save it on app folder ? not in the document?
thanks i already stars your best fork 💃

Sorry , We can't do it . iOS does not allow us do that.

@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

@matrixreal , you can use ${Documents}, ${Library}, ${Caches}, ${tmp} . I think that's enough.

@matrixreal
Copy link

social.showPostDialog seem not access to document folder
the png file is there but when call the showpostdialog with that image not apear

@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

@matrixreal , Could you test phoboslab#540 ?
I am very sure that social.showPostDialog could access Documents folder .

@matrixreal
Copy link

ok
just copy what your link and paste it to index.js
i got crash (ios7)
crash

@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

@matrixreal , thanks . I don't have iOS 7.
Now update my fork version , I changed some codes.
Please Test again, thanks

@matrixreal
Copy link

same error

@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

@matrixreal , thanks .

Please Update and test again .

@matrixreal
Copy link

this could explain why showpostdialog can't access to documents ? no ? right ?

@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

No. Crash because the queue was lost.

@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

@matrixreal , Are there same errors ?

@matrixreal
Copy link

same error
but i see that you change something just now
so i will download again and test

@matrixreal
Copy link

can you pleas check again if showpostdialog can access to documents ?

@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

I am very sure that social.showPostDialog could access Documents folder .

@finscn
Copy link
Owner Author

finscn commented Sep 7, 2015

Now , I download iOS 7.1 SDK , and Test in simulator. That's OK.
Please update and test again

@matrixreal
Copy link

still same here
ios 7.1.2 iphone 4s

@finscn
Copy link
Owner Author

finscn commented Sep 8, 2015

what's same? no image or crash ?

@matrixreal
Copy link

@finscn
now it work perfectly , some times crash but good better than nothing.... wow after 2 days of searching
i could never done it without you
thanks a lot ... if you want promote your app just write me

@matrixreal
Copy link

@finscn
last question
when i use var context = canvas.getContext("2d"); (to make apputils saveimage work)
i got screencanvas created 6 times ? do you have an idea ?
sans titre

@finscn
Copy link
Owner Author

finscn commented Sep 8, 2015

"some times crash" in device or simulator ? or both ? Could you get the error message ?

"created 6 times " : I don't know , In my test case , there is no this problem .

@matrixreal
Copy link

crash in device .... i don't use simulator since there are a lot of restrictions etc ... so i prefer real device
ok i will post the log error as soon as it crash

@matrixreal
Copy link

@finscn
hahaaa now apputils is become good features than before

@matrixreal
Copy link

@finscn
is there a way to share an image like in showpostdialog but in openshare?

@finscn
Copy link
Owner Author

finscn commented Sep 11, 2015

No. the iOS API doesn't allow we do that.

@matrixreal
Copy link

@finscn
are you sure ?
i have an app in my phone that share the snapshoot using openshare dialog

@finscn
Copy link
Owner Author

finscn commented Sep 11, 2015

@matrixreal
Copy link

works perfectly thanks

@matrixreal
Copy link

hi,

i found that construct 2 (the tool i use to make html5 games) is using the line below to create canvas

var ctx = canvas.getContext("2d");

and the appUtils.saveImage call need the canvas initialize by var context = canvas.getContext("2d");

how can i modify it ? to use the ctx and not context ?

thanks

@matrixreal
Copy link

@finscn
i think i found it
this is working saveImage is only working with canvas 2d and not canvas webgl
i think it need update

@finscn
Copy link
Owner Author

finscn commented Oct 5, 2015

  1. "ctx" or "context" is not the point. you can use any name of variables .
  2. It supports WebGL .

@matrixreal
Copy link

yes yes thats okay ...
but for sure
the saveimage call is not working on webgl mode

@finscn
Copy link
Owner Author

finscn commented Oct 5, 2015

saveImage supports WebGL . I test it in pure WebGL , not construct 2 . Maybe the problem is about something else ,not 2D or WebGL

@finscn
Copy link
Owner Author

finscn commented Oct 5, 2015

Sorry , I make a mistake. I've not tested it with WebGL. I will try it later.

@matrixreal
Copy link

:D* you are welcome ....

@matrixreal
Copy link

@finscn
hi any news ? about the webgl

@matrixreal
Copy link

@finscn
any news please ?

@finscn
Copy link
Owner Author

finscn commented Oct 12, 2015

@matrixreal , Sorry , My macbook is breakdown (in fixing). Now I work on a windows PC . So I don't do anything about Ejecta . My macbook will be back in Next week

@finscn
Copy link
Owner Author

finscn commented Oct 18, 2015

@matrixreal , update and try again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants