Capture Image Data in k3d

Asked by Tom Riedl

Hello Kevin,

Good work - k3d is quite impressive.

I would like to pre-generate a series of images of a rotating image. I was hoping to use javascript getImageData to do so at the appropriate place in one of your *.js modules. I'be tried to find where in the code I might do this (presumably where the code does a putImageData or drawImage function call in putting out the rotated image) - but to no avail.

Could you tell me where I can do what I'm trying to do using your Example3.html. Whatever you can provide would be very helpful I'm sure and appreciated.

Regards,
Dr. Tom Riedl | <email address hidden>

Question information

Language:
English Edit question
Status:
Expired
For:
canvas K3D Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Kevin Roast (kevtoast) said :
#1

Hello,

Thanks. Yes you can definitely do that, I use exactly this technique to "pre render" 3D graphics as individual image frames for the games Arena5 here: https://github.com/kevinroast/arena5/blob/master/scripts/arena_prerender.js
You simply retrieve the image data from the underlying canvas buffer on each frame render e.g.
var img = new Image();
img.src = buffer.toDataURL("image/png");
That will capture the contents of the canvas bitmap into new Image object. You can then manipulate that image object such as putImage to another canvas or similar - which is exactly what is done in the game code to render frames for each pre-rendered graphic that was generated with K3D.

Kevin

Revision history for this message
Tom Riedl (drtom) said :
#2

Thank you, Kevin for your helpful reply.
Best regards,
Tom [ from New York City ]
-------------------------------------------------------------------------------
Dr. Thomas Riedl | 212.505.9853 | <email address hidden>
<mailto:<email address hidden>>

On 7/8/2016 10:02 AM, Kevin Roast wrote:
> Your question #296115 on canvas K3D changed:
> https://answers.launchpad.net/canvask3d/+question/296115
>
> Status: Open => Answered
>
> Kevin Roast proposed the following answer:
> Hello,
>
> Thanks. Yes you can definitely do that, I use exactly this technique to "pre render" 3D graphics as individual image frames for the games Arena5 here: https://github.com/kevinroast/arena5/blob/master/scripts/arena_prerender.js
> You simply retrieve the image data from the underlying canvas buffer on each frame render e.g.
> var img = new Image();
> img.src = buffer.toDataURL("image/png");
> That will capture the contents of the canvas bitmap into new Image object. You can then manipulate that image object such as putImage to another canvas or similar - which is exactly what is done in the game code to render frames for each pre-rendered graphic that was generated with K3D.
>
> Kevin
>

Revision history for this message
Tom Riedl (drtom) said :
#3

Hello again Kevin,

Thanks again -
There's something (simple?) I'd like to do: rotate a 2-d image
simultaneously around all 3 - X, Y, Z - axis with the axis intersecting
at the center of the image. (I don't want to rotate a 6-sided rendition
of the image, but only the 2-d - flat - image.)
* I would greatly appreciate it if you could direct me to exactly WHERE
in your code I can do this. (There is a fair amount of code and it's not
clear where the relevant code is.)

Regards,
Tom

On 7/8/2016 10:02 AM, Kevin Roast wrote:
> Your question #296115 on canvas K3D changed:
> https://answers.launchpad.net/canvask3d/+question/296115
>
> Status: Open => Answered
>
> Kevin Roast proposed the following answer:
> Hello,
>
> Thanks. Yes you can definitely do that, I use exactly this technique to "pre render" 3D graphics as individual image frames for the games Arena5 here: https://github.com/kevinroast/arena5/blob/master/scripts/arena_prerender.js
> You simply retrieve the image data from the underlying canvas buffer on each frame render e.g.
> var img = new Image();
> img.src = buffer.toDataURL("image/png");
> That will capture the contents of the canvas bitmap into new Image object. You can then manipulate that image object such as putImage to another canvas or similar - which is exactly what is done in the game code to render frames for each pre-rendered graphic that was generated with K3D.
>
> Kevin
>

Revision history for this message
Launchpad Janitor (janitor) said :
#4

This question was expired because it remained in the 'Open' state without activity for the last 15 days.