BlackBerry. Pictures of the manned

Source: Internet
Author: User

Loading of images (for reference only)


Description

1, put the picture to be loaded, put in the current project root directory, then the path of the picture is: app/native/picture name;

2. The image used in the following discussion is in PNG format because of the custom function:

bbutil_load_texture

, the picture you open is in PNG format and can be changed on your own if required;

3, the following discussion of the pictures and other resources, are included;

4, switch the picture is the work of the control module, here use the virtual keyboard as an example of event processing.

General Method:

First, Create a context (method slightly);

Second, initialize EGL, you can use custom functions:

Bbutil_init_egl

To initialize, this function will be defined in bbutil.h after a new project is created;

Third, affirm (star) screen events and navigator events, the library functions can be screen_request_events functions and navigator_request_events into Statement of the line;

Import pictures, import pictures, you can modify the initialization of the Helloworlddisplay example init () function is init (char filename[]), and the file The name parameter is used to

intbbutil_load_texture (const char* filename, int* width, int* height, float*tex_x, float* tex_y, unsigned int* Tex); /c10>

The first parameter in the.

FileName can be passed from the main function to enable different images to be opened. There is a library function in bbutil_load_texture

Glviewport;

This function has four parameters, the first two are the left side of the picture's lower left (planar Cartesian coordinate system), and the next two parameters are the height and width of the picture display.

Five, add the control module (this piece of code can be copied completely, and then add the function keys themselves):

Code:

void Handlescreenevent (bps_event_t *event)

{

Screen_event_tscreen_event = screen_event_get_event(event);

intscreen_val;

Screen_get_event_property_iv (Screen_event, Screen_property_type, &screen_val);

Switch (Screen_val) {

Case Screen_event_keyboard:

Screen_get_event_property_iv (Screen_event, Screen_property_key_flags,&screen_val);

if (Screen_val & Key_down) {

Screen_get_event_property_iv (Screen_event, Screen_property_key_sym,&screen_val);

printf ("The '%c ' key was pressed\n", (char) screen_val);

Fflush (stdout);

Switch (Screen_val) {

Case Keycode_i:

Display the email layout with "Send" enter key

virtualkeyboard_change_options (Virtualkeyboard_layout_email,virtualkeyboard_enter_send);

break;

Case keycode_t:

Virtualkeyboard_show ();

break;

Case Keycode_o:

Display the phone layout with "Connect" enter key

virtualkeyboard_change_options (Virtualkeyboard_layout_phone,virtualkeyboard_enter_connect);

break;

Case Keycode_p:

Display the default layout with default enter key

virtualkeyboard_change_options (Virtualkeyboard_layout_default, Virtualkeyboard_enter_default);

break;

Case Keycode_h:

Hide the keyboard

Virtualkeyboard_hide ();

break;

Case Keycode_down:

Increment Rotation angle

a++;

break;

Case KEYCODE_UP:

Decrement rotation angle

a--;

break;

Case Keycode_right:

a++;

break;

Case Keycode_left:

a--;

break;

default:

break;

}

}

break;

}

Where A is a global variable: static int a = 0;

Call this function in the Mian function Wei:

if (event) {

int domain = bps_event_get_domain(event);

if (Domain = = screen_get_domain()) {

Handlescreenevent (event);

} else if (domain = = navigator_get_domain())

&& (navigator_exit== bps_event_get_code(event))) {

e = 1;

}

}

E is defined as inte = 0; When e = 1 o'clock, it jumps out of the loop.

When a is equal to a different value, the value of the filename is changed to achieve the effect of switching the picture.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.