How to add Screen Shot feature in kinoma applicaiton

edited April 2016 in Kinoma Studio

I want to save current screen as jpeg file. Is it possible?


  • Yes, this is possible. You have a couple of options, depending on what you're trying to do.

    1) If you just want to pull screenshots manually, the easiest way to do that is by using a web browser on the same network as your device. If, for instance, I have a Kinoma Create on my network at IP address, I could open this url in a web browser to get a screen shot: Please note that if you have a password set for your device in the Debugging settings, you will be prompted for that password.

    2) If you want to save screenshots locally on the device for further processing, you can use the function K4.captureScreen(immediate, x, y, width, height); The immediate parameter picks whether or not to trigger the "flash" effect that the screen shot function normally does. x and y are the upper left corner of the screen to capture. width and height are the size to capture. So, capturing the full screen on Kinoma Create could look like K4.captureScreen(false, 0, 0, 320, 240);

    The return value from the second mechanism is an ArrayBuffer with the bitmap of the screen. You could then use the Files API to save the value locally, or you could send it directly over HTTP to a web service, etc.


    — Andy

  • Oh! I just noticed that this is not in the Kinoma Create forum, but rather Kinoma Studio. So, I should ask what platform you're trying to do this on. Kinoma Create or elsewhere?

    — Andy

  • I want to do it for linux platform not for kinoma create

  • Understood. That's a bit out of my domain, but another member of our team will put something together to demonstrate how to do what you want ASAP.

    — Andy

  • Hey Andy

    any updates from your side from my side I found below file " build/linux/kpl/KplScreenLinuxK4.c" which has getting bit map function so this might help but I dont know exact API/function to get this done.

    • Vijay
  • Answer ✓

    Hi Vijay,

    We've whipped up a sample to show off how to do this, but it hasn't propagated to github quite yet. I'll let you know here when it does. (Likely sometime over the weekend.)

    — Andy

  • Answer ✓

    Vijay -

    We've published a screen -capture sample app that shows how to capture the contents of the screen into a JPEG image file. The technique will work on KinomaJS Linux and desktop platforms.

    Regards, Brian

  • edited May 2016

    Hi Brian

    Does it make any difference if OpenGL is enabled on target hardware ? I am getting Black screen image.

    and I am calling it from onCreate() { container.invoke(new Message("/capture"), Message.BUFFER); } because once view created I want to save the view in jpeg file


  • Answer ✓

    Vijay -

    Trying to capture the screen from onCreate() is likely too early, since the containment hierarchy hasn't yet been created. Please try capturing the screen from the onDisplayed() event.

    Regards, Brian

  • Thanks Brian and Andy !!! Appreciate your eagerness to answer the questions :)


  • just one thing here can we save images into other format as well ? bmp , png etc ?

    -- Vijay

  • edited May 2016 Answer ✓

    Vijay -

    The screen-capture sample app leverages the Layer.prototype.setResponseJPEG() function to capture the screen image into a JPEG file. This API doesn't support any other image file formats.

    That said, KinomaJS is open source, which gives you the ability to customize the platform to suit your needs. KinomaJS includes a BMP compressor that can be used as well.

    You can prototype compressing to BMP format by changing the KPR_layer_setResponseJPEG function in kprLayer.c. Try changing this:

    bailIfError(FskImageCompressNew(&comp, 0, "image/jpeg", bounds.width, bounds.height));

    To this:

    bailIfError(FskImageCompressNew(&comp, 0, "image/bmp", bounds.width, bounds.height));

    The KinomaJS image compression APIs choose the image compressor based on MIME type.

    Regards, Brian

  • Thanks Brian it works for me :)

Sign In or Register to comment.