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
Regular Contributor
MindOperations
Posts: 64
Registered: ‎03-04-2010
My Device: 9930
My Carrier: VZN
Accepted Solution

img_lib_attach(): How to questions?

I am very confused on how to load this.

 

I understand the documentations code:

 

img_lib_t ilib = NULL;
int rc;
rc = img_lib_attach(&ilib);

 

How do I attach img_codec_png.so  so it doesnt give me a undefined reference error.  I am a bit confused on what the documentation says on the config file in reference to this funtion.

 

I am trying to insert it into the main function for a learning file I have been working on. If I solve this I believe it will help me with the img_load_file() error im recieving.  The working code is below that will give you a black parent window and groups a child window to it.  The child is not defined or pushed to the screen yet.(Excuse the if case funtions,  trying to practice smart coding practices.)

 

#include <screen/screen.h>
#include <stdlib.h>	
#include <stdio.h>
#include <img/img.h>

screen_context_t	homeContext = 0;
screen_window_t		homeWindow = 0;//parent window
static const char 	*homeGroup = "Home Windows";
screen_buffer_t		homeBuffer;
int hformat_w 	= SCREEN_FORMAT_RGBA8888;
int husage_w	= SCREEN_USAGE_NATIVE;
int hvis		= 0;		
int hcolor		= 0xff000000;
int hshap[4]	= {0, 0, 1, 1};	
int hdims[2]	= {0, 0};	
int hcount = 0;		

screen_window_t		hcscreen_w = 0;//child window

int main()
{
	if(screen_create_context(&homeContext, SCREEN_APPLICATION_CONTEXT) != 0)
	{
		return EXIT_FAILURE;
	}

	if(screen_create_window(&homeWindow, homeContext) != 0)
	{
		screen_destroy_context(homeContext);
		return EXIT_FAILURE;
	}

	if(screen_create_window_group(homeWindow, homeGroup) != 0)
	{
		return EXIT_FAILURE;
	}

	if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_FORMAT, &hformat_w) != 0)
	{
		return EXIT_FAILURE;
	}

	if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_USAGE, &husage_w) != 0)
	{
		return EXIT_FAILURE;
	}

	if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_VISIBLE, &hvis) != 0)
	{
		return EXIT_FAILURE;
	}

	if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_BUFFER_SIZE, hshap+2) != 0)
	{
		return EXIT_FAILURE;
	}

	screen_get_context_property_iv(homeContext, SCREEN_PROPERTY_DISPLAY_COUNT, &hcount);

	screen_display_t *hdisps = calloc(hcount, sizeof(screen_display_t));
	screen_get_context_property_pv(homeContext, SCREEN_PROPERTY_DISPLAYS, (void **)hdisps);

	screen_display_t hdisp = hdisps[0];
	free(hdisps);

	screen_get_display_property_iv(hdisp, SCREEN_PROPERTY_SIZE, hdims);

	if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_COLOR, &hcolor) != 0)
	{
		return EXIT_FAILURE;
	}

	if(screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_SOURCE_SIZE, hdims) != 0)
	{
		return EXIT_FAILURE;
	}
	int hpos[2] = { -hdims[0], -hdims[1] };
	screen_set_window_property_iv(homeWindow, SCREEN_PROPERTY_SOURCE_POSITION, hpos);

	if(screen_create_window_buffers(homeWindow, 1) != 0)
	{
		return EXIT_FAILURE;
	}

	screen_get_window_property_pv(homeWindow, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&homeBuffer);
	screen_post_window(homeWindow, homeBuffer, 1, hshap, 0);


	if(screen_create_context(&homeContext, SCREEN_APPLICATION_CONTEXT) != 0)
	{
		return EXIT_FAILURE;
	}

	if(screen_create_window_type(&hcscreen_w, homeContext, SCREEN_CHILD_WINDOW) != 0)
	{
		screen_destroy_context(homeContext);
		return EXIT_FAILURE;
	}

	if(screen_join_window_group(hcscreen_w, homeGroup))
	{
		return EXIT_FAILURE;
	}
	
	if(screen_destroy_window(homeWindow) != 0)
	{
		return EXIT_FAILURE;
	}

	if(screen_destroy_context(homeContext) != 0)
	{
		return EXIT_FAILURE;
	}
	
return 0;
}

 

 

 

 

 

Brandon Clark
The Mind Company | www.themindspot.com

Please use plain text.
Regular Contributor
MindOperations
Posts: 64
Registered: ‎03-04-2010
My Device: 9930
My Carrier: VZN

Ok, understand the config portion.

I understand how the img_lib_t points the config file to ilib variable.  This still wont work, I have the the nutrino img.h header included.  The error I keep getting makes it seem like the file or library isnt there.  Any suggestions???

Brandon Clark
The Mind Company | www.themindspot.com

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

Re: Ok, understand the config portion.

You need to link against libimg.  Add "img" to your list of libraries.

 

Please use plain text.
Regular Contributor
MindOperations
Posts: 64
Registered: ‎03-04-2010
My Device: 9930
My Carrier: VZN

Re: Ok, understand the config portion.

Thank you very much.  Your answer makes sense to my belief something isnt being included.  

 

Now for the beginers question how do I add this link to the library, sorry.  I am not able to try this out currently perhaps later but I would assum I simply add the lin "-l img" after clicking the new button in linked libraries?

Brandon Clark
The Mind Company | www.themindspot.com

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

Re: Ok, understand the config portion.

Under Project->Properties:

C/C++ Build

Settings

QCC Linker

Libraries

 

Click the + and add "img"

 

Please use plain text.
Regular Contributor
MindOperations
Posts: 64
Registered: ‎03-04-2010
My Device: 9930
My Carrier: VZN

Re: Ok, understand the config portion.

Dont have my playbook to test simlation but ide recognizes the load funtion!  Thanks!!!

Brandon Clark
The Mind Company | www.themindspot.com

Please use plain text.