Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus
Accepted Solution

screen_window_t

I'm trying to capture a screenshot of my app using

 


screen_read_window(screen_window_t win, screen_buffer_t buf, int count, const int *save_rects, int flags)

 for screen_window_t im getting 'win' is used uninitialized in this function [-Wuninitialized]

 

 

I belive i'm getting this because my app is largely based off QML so i never created windows in c++, my question is how could i go about putting everything i have into a window, or how to get the window id of everything thats already being show from qml

 

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: screen_window_t

[ Edited ]

Searching this forum for "screenshot" found this a few hits down: http://supportforums.blackberry.com/t5/Cascades-Development/Screenshot-Render-entire-screen/m-p/2200...

 

Edit: fixed link to include http


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: screen_window_t

that thread is how i've got as far as i have :smileywink:  with it

 

screen_read_window(GLOBALS_PTR()->app()->mainWindow()->handle(), screenshot_buf, 0, NULL ,0);

tells me  GLOBALS_PTR doesnt exist, so i tore it down & went to the basics 

screen_window_t win;
screen_read_window(win, screenshot_buf, 0, NULL ,0);

 however once i included that, it tells me that win is an unused variable

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: screen_window_t

I don't know what his GLOBALS_PTR() is, but it's unique to his own app. You need to get the mainWindow from the Cascades Application object... that's what mainWindow() is returning there. You can't simply take an uninitialized var like "win" and expect it to be useful in this case... it's a handle to an existing thing, so it must be set correctly whereas in your code it has some stray leftover value in it from whatever was on your stack at that moment.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: screen_window_t

Thanks, you're explanation helped me understand how it works which resulted in me giving this a shot

 

screen_read_window(Application::instance()->mainWindow()->handle(), screenshot_buf, 0, NULL ,0);

 it doesnt give any errors & my app runs, not sure if i'm calling it from qml properly though

 

void myApp::capture(int width, int height, screen_context_t context)

 using just the desired height/width provides no results

Button {
    onClicked: {
        myApp.capture(768,1280, ?context?);
        }
    }

 

Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: screen_window_t

After some reading on how the screen & window api's work I have achieved working results

 

since i'm using qml, i removed the screen context declaration in 

void myApp::capture(int width, int height)

 & put it inside the control instead

void myApp::capture(int width, int height)
{
screen_context_t context; screen_create_context(&context, 0);
//rest of code
}

 also added shared file access to my bar descriptor

 

the rest of the code can be found here