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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Regular Contributor
prathipa84
Posts: 55
Registered: ‎03-14-2012
My Carrier: none
Accepted Solution

Aspect ratio using libscreen for video frame

Hello, 

 

 I am getting the video frame in the size 352*288 resolution, when i draw that frame using the libscreen, how to maintain the aspect ratio.. My code is

 

int ret = screen_get_buffer_property_pv(m_screen_pixel_buffer, SCREEN_PROPERTY_POINTER, (void**) &ptr);
int len = width*height*1.5;
memcpy(ptr, data, len);

screen_buffer_t screen_buffer;
screen_get_window_property_pv(m_screen_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**) &screen_buffer);

 

int attribs[] = { SCREEN_BLIT_SOURCE_WIDTH, width, SCREEN_BLIT_SOURCE_HEIGHT, height, SCREEN_BLIT_END };
screen_blit(m_screen_context, screen_buffer, m_screen_pixel_buffer, attribs);

int dirty_rects[] = { 0, 0, width, height };// full screen display(not working)
screen_post_window(m_screen_window, screen_buffer, 1, dirty_rects, 0);

 

 

Can anyone help in this!!!!!!!!!!

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 539
Registered: ‎11-29-2011
My Carrier: other

Re: Aspect ratio using libscreen for video frame

have you considered specifying the destination blit parameters?  x, y, width, height?

 

http://developer.blackberry.com/native/reference/bb10/screen_libref/topic/group__screen__blits_1scre...

 

Please use plain text.
Regular Contributor
prathipa84
Posts: 55
Registered: ‎03-14-2012
My Carrier: none

Re: Aspect ratio using libscreen for video frame

Hello,

          Actually I am new to this screen functions. I have used code which i attached previously. I dont know whether attrib are set for destination blit parameters... In the attribs[], thw width and heigth i have specified is the width and height of the frame.

 

What to do for maintaining the aspect ratio, now my video is displaying in fullscreen of the BB device..

 

Thanks

 

Please use plain text.
Regular Contributor
prathipa84
Posts: 55
Registered: ‎03-14-2012
My Carrier: none

Re: Aspect ratio using libscreen for video frame

 

Hello,

 

It may be usefull if you say what to set in my code or any sample apps maintaining the video with aspect ratio...

 

Thanks..

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 539
Registered: ‎11-29-2011
My Carrier: other

Re: Aspect ratio using libscreen for video frame

[ Edited ]

it's basic math.  you're asking for a source image of a certain size: W1 x H1 to be drawn in a destination area of a certain size: W2 x H2.

If W1/H1 is differnt from W2/H2 then your image will be distorted.  So just make sure that you set the appropriate destination width and height so that your image is not distorted.

 

It is a simple matter to read the documentation at the link I provided*:

 
SCREEN_BLIT_DESTINATION_WIDTH
The following element contains the width of the rectangle into the destination buffer that defines the area that will be copied into. The width is in pixels. The width does not have to match the source width. If the destination width is larger, the source rectangle will be stretched. If the destination width is smaller than the source width, the image will be compressed.

If SCREEN_BLIT_DESTINATION_WIDTH is not specified, the destination buffer width will be used.

 
SCREEN_BLIT_DESTINATION_HEIGHT
The following element contains the height of the rectangle into the destination buffer that defines the area that will be copied into. The height is also in pixels. The height does not have to match the source height. If the destination height is larger, the source rectangle will be stretched. If the destination height is smaller than the source height, the image will be compressed. Note that the horizontal and vertical scale factors don’t have to be equal. It is acceptable to specify a source width that is larger than the destination width while the source height is smaller than the destination height, and vice versa.

If SCREEN_BLIT_DESTINATION_HEIGHT is not specified, the destination buffer height will be used.

 

If you are still stuck, I will write you some example code, but you should aim to either set SCREEN_BLIT_DESTINATION_WIDTH equal to the window width and then calculate an appropriate value for SCREEN_BLIT_DESTINATION_HEIGHT based on your aspect ratio, or vice versa.

 

You will first need to read back the width and height of your destination window using screen_get_window_property_iv() and retrieving SCREEN_PROPERTY_BUFFER_SIZE.

 

Cheers,

Sean

 

*I just noticed that I cut & pasted this from the playbook docs, but the BB10 docs describe this similarly.

Please use plain text.
Regular Contributor
prathipa84
Posts: 55
Registered: ‎03-14-2012
My Carrier: none

Re: Aspect ratio using libscreen for video frame

Thanks for your reply... I got my code working!!!!!!!!!!!!

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 539
Registered: ‎11-29-2011
My Carrier: other

Re: Aspect ratio using libscreen for video frame

cool.. good to hear!

 

Please use plain text.