examples of libimg (img_convert_data)?

I try to use libimg to load and display an image. It is the work of 3/4. Specifically, the image is at RGB888 format, and the Cascades ImageData object RGBX, if I get a fresh crushed and somewhere between mono effect and color.

I try to use img_convert_data() to convert the data, but it doesn't seem to do anything. The destination buffer that I spell him unchanged. If I memset 0xD0 buffer before calling img_convert_data(), then the image is displayed as a gray solid. img_convert_data() returns IMG_ERR_OK, so I don't even have a mistake to work with...

An abbreviated version of what I have is:

img_t img;

img_format_t new_format = IMG_FMT_RGBA8888;

uint8_t * new_data;

size_t new_bpl;

int rc;

RC = img_load_file (ilib, filename, NULL, &img);)

new_bpl = IMG_FMT_BPL (new_format, img.w);

new_data = (uint8_t *) malloc(new_bpl * img.h);

RC = img_convert_data (img.format, img.access.direct.data, new_format, you see, N);

I tried some numbers for N ("the number of samples to convert"), because I do not know what is required. 1 does not work, does not img.h, new_bpl * img.h segfaults...

What Miss me?

Hey, I'm working on this picture library on QNX. The problem you are having is that you pass in the number of bytes to img_convert_data() instead of the number of 'samples' that is, pixels. For example, IMG_FMT_RGBA8888 has four bytes per pixel, so you ask to convert four times more data is present.

I tried my best to reproduce your example with the following program:

#include 
#include 
#include 
#include 

#include 

int main(int argc, char ** argv)
{

    if (argc != 2) {
        printf("Usage: %s [filename]\n", argv[0]);
        printf(" e.g. %s /path/to/some/photo.jpg\n", argv[0]);
        return 1;
    }

    // attach image library (loads codecs)
    img_lib_t ilib;
    int rc = img_lib_attach(&ilib);
    if (rc != IMG_ERR_OK) {
        printf("img_lib_attach() failed: %d\n", rc);
        return 1;
    }

    // load image
    img_t img;
    memset(&img, 0, sizeof(img_t));
    // I'm putting this here to make sure I already have an RGB image to convert up to RGBA later
    img.format = IMG_FMT_RGB888;
    img.flags |= IMG_FORMAT;
    rc = img_load_file(ilib, argv[1], NULL, &img);
    if (rc != IMG_ERR_OK) {
        printf("img_load_file() failed: %d\n", rc);
        return 1;
    }
    printf("img_load_file() succeeded\n");

    // convert image
    img_format_t new_format = IMG_FMT_RGBA8888;
    size_t new_bpl = IMG_FMT_BPL(new_format, img.w);
    uint8_t * new_data = malloc(new_bpl * img.h);
    rc = img_convert_data(img.format, img.access.direct.data, new_format, new_data, img.h * img.w);
    if (rc != IMG_ERR_OK) {
        printf("img_convert_data() failed: %d\n", rc);
        return 1;
    }
    printf("img_convert_data() succeeded\n");

    return 0;
}

I tested with a PNG that I and the conversion worked successfully.

In general, it's probably more idiomatic to specify the destination format before loading the image to let the img lib to do the conversion for you. The advantage is that the img_t will be updated with the data, as well as good stride, format indicators, etc.

Chris

Tags: BlackBerry Developers

Similar Questions

  • On the use of libimg Adivice.

    I loaded the img lib and my png file, now how do I use the libimg to make it to the screen. I do not understand why you clean after you load the file before the actual use of the img.

    Where should I go from here? Are some tips on how to work with the UI outside gl or air would be appreciated.

    You can use the img library to load an image and you can use the library of the screen to draw on the screen, but the two do not have an explicit meeting in the middle. In other words, there is nothing in img that says: 'this draw to the screen', and there is nothing in the screen that says "draw this image.

    The library of the screen provides tampons... pads of screen that are directly related to the screen and pixmap buffers that may be associated with images off screen and other presentations.

    Some of the applications in the "examples of NDK" on github.com/blackberry example shows various pieces of what you need to do. For example, look at the app 'GestureSample '. In this example, the function "load_image" starts the process of reading of an image file. It implements the callback functions, one of which, 'decode_setup', is called by the library to manage the content of the image. It allocates a buffer of screen, then gets a pointer to the data buffer area, put the pointer in the structure of the img, that uses the library img actually load the image bits into the screen buffer. The image is thus placed directly into a screen buffer, which ultimately comes on-screen. It's a little something in a sense, because both api are not related, but you're basically copy and paste a pointer to buffer a api in the loading of another sequence. Otherwise, you'd be more likely to allocate a pixmap buffer and put in place the pointer so that the image will load in this buffer. To make it really later, you would go back to the library of the screen and the 'screen_blit' function to copy the image, or a part of it, as long as you want to go in screen coordinates.

    When you blit an image from a buffer in a screen buffer, you also seem to need to take care of cropping of the blit to the screen buffer limits, as cropping does not seem to be applied automatically.

    In short, these two libraries are very (very) low level and require a good amount of code intensely grungy to do something as simple as getting an image from a file to the screen.

    Senior level packages, such as Qt, take care of all that stuff for you. You must decide whether to go down to the lower level and worry about a lot of things or let the top-level packages take care of it for you.

  • How to change the gesture example application to load a different image after initial load

    The sample application 'Gesture' is a good start for me, since I want to load and display a picture full screen.

    However, my application needs to change the image that is displayed thereafter.

    I managed to load the new JPEG image via:

    ...

    io_stream_t * memory_stream = io_open (IO_MEM, IO_READ, num_jpeg_bytes, jpeg_bytes);

    RC = img_load (ilib, memory_stream, & legends, &img);)

    ...

    ... but the new image is not displayed on the screen.  I guess that's because the decode_setup function that is used to load the image when the IPL does not have to then change the image, but I don't know how it should be changed.

    I read:

    https://bdsc.webapps.BlackBerry.com/native/reference/com.QNX.doc.libimg.lib_ref/com.QNX.doc.libimg.l...

    ... but it does not tell me something I already know.

    I guess the question is this: If you load an image into a structure img_t, how can I take this img_t and update the screen to display the image full screen?

    Thank you!

    Daniel

    Hi Daniel,.

    The legend of decode_setup provided should load successfully all significant images in memory buffer rendering. However that alone does not display the image on the screen. You must call screen_post_window() after your call to img_load to make your changes in the visible rendering buffer.

    See:

    https://bdsc.webapps.BlackBerry.com/native/reference/com.QNX.doc.screen.lib_ref/topic/rscreen_post_w...

    For more information, or the main() function of the sample of actions for an example.

    Kind regards

    Jeff

  • I just bought the last Apple TV - I can't seem to connect with the App Store and Siri is completely useless. This is an example of how Apple is unable to produce a useful product?

    I just bought the last Apple TV - I can't seem to connect with the App Store and Siri is completely useless. This is an example of how Apple is unable to produce a useful product?

    Hello

    Be sure to follow the instructions in this article to support > set up your Apple TV (4th generation) - Apple supported

  • I think I have to reset the SMC on my MacBook Pro, but I need MUCH more information on my MacBook Pro. For example, is the battery removable?

    I think I have to reset the SMC on my MacBook Pro, but I need MUCH more information on my MacBook Pro. For example, is the battery removable?

    Depends on what year it is.

  • Keyboard entry displays garbage - is OK in IE and Chrome. Abdelkrim will show for example 123' -! random characters every time

    When I type for example aaaaaaaaaaaa what follows is displayed asdfghjkl; ' '-the characters are different each time.

    This just started happening today. IE and Chrome doesn't and characters appear when they are typed.

    I uninstalled and reinstalled Firefox but still the same

    What security software do you have?

    Some security software a typo protection or Anti-Keylogger features that can cause this.

    Start the computer in Mode safe mode with network support Windows (on the startup screen, press F8) to see if that helps.

  • Page Firefox blocks, led busy, very low cpu on some sites. I have an example.

    Firefox 41.0, win 10 Pro x 64.
    Recently (possibly before v.41) pages Firefox hang with very low cpu on some sites.
    Firefox itself is not hung, but for this tab, the indicator of the clock continues ticking.
    I open the problem while another tab has the problem.
    Some data on the website are generally displayed (context?).
    There may be a redirect/refresh any (full proposal).
    Note: in this case, the web site is grayed out.
    Example: https://www.code42.com/store/
    Problem is when I navigated to the URL above. Also occurred when I pasted the URL.
    Works in Version Chrome 45.0.2454.101 m.
    Working on board 20.10240.16384.0

    Note: right now, I'm trying to upload an image, the download is not finished. Ticks of the clock.

    I will try to present this anyway.

    I was about to follow the instructions in the above message, but tried the web site to verify that the problem continues. There can be no. I don't know what I've done (maybe I cleared the cache I've been poking).
    Anyway. Please close this incident.
    And thanks for your help.

  • Phone wants to know a port number. What is c? Their example. 0101

    I am going through the pain of installing my email on my phone. I was able to fill in all, but what is called a port number. The phone gives an example of 0101

    Hello

    It's not something that I think is related to Firefox for Android, but I'll do my best to help.

    The e-mail on your application software a Port number to help it connect to your mail service. Each mail service provider has different settings, so I recommend you contact or have a look in their help files for orientation. This will usually lies in the sections to make the connection by using the third-party e-mail software.

    I hope this helps, but if not, please come back here and we can look at another solution for you.

  • Firefox does not comment based on Facebook on all websites (for example Huffpost): I tried the safe mode, disabling anti-ad... nothing works.

    I can get on FB and post. etc., but sites that use them commenting on do not display comments. I've tried safe mode, re - install Firefox: not to go.

    It's complicated. There are many links in the chain...

    You want to check if Firefox is actually sending a request to Facebook many different servers and receive a normal response? Here's how you can try it.

    While watching the HuffPost (or other) page, press Ctrl + Shift + k to open the Web Console in the lower part of the tab along its top edge, click Network. Then reload the page and network monitor should start to fill with dozens of URL in the order that makes Firefox the application.

    After he calms down, you can scroll down or click on the header of the column field sort by site and search queries to these areas. They were called in the order in my little test, among a bunch of other things:

    For example, if there is no request to connect.facebook.net, then a script blocker or a blocker Tracker can kick in. If there is no request for html pages, then the script could be at fault or another type of block can be considered.

    Note: I stay connected on Facebook, so being connected may have some influence on this point that I'm not aware of.

  • When you type a query in the bar always double the third letter, for example, research, if I want to write a 'youtube' written "youutube" what to do, help

    When you type a query in the bar always double the third letter, for example, research, if I want to write a 'youtube' written "youutube" what to do, help

    Hello chilli.willi, try Firefox Safe Mode to see if the problem goes away. Firefox Safe mode is a troubleshooting mode that temporarily disables hardware acceleration, restores some settings and disables add-ons (extensions and themes).

    If Firefox is open, you can restart Firefox Safe mode in the Help menu:

    • Click the menu button

      click Help

      then select restart with disabled modules.

    When the Firefox Safe Mode window appears, select "start mode safe."

    If the problem is not present in Firefox Safe Mode, your problem is probably caused by an extension, theme or hardware acceleration. Please follow the steps described in the section Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems to find the cause.

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before you open Firefox for normal use again.

    When find you what is causing your problems, please let us know. This might help others with the same problem.

  • Is it possible to sync only bookmarks in one device, for example and all the other stuff between other devices?

    Hello.

    I have 3 devices. 2 of them are at work, so I don't want to sync items such as extensions (xnotifier, for example, is to synchronize my CPA), passwords for my PC at home with these two devices. But I want to synchronize my bookmarks and other things. Is it possible to separate between different devices sync settings?

    Thank you.

    You may need to use two separate sync accounts, if this is not possible with a single account.
    As you cannot use both accounts at the same time on a device, you will need to disconnect the computer which is the main device and (temporarily) connect to another account only synchronize to the other account to sync bookmarks.

  • When I type in a firefox window, typing backwards, for example ABCD appears as DCBA solutions?

    I am a passionate user of Mozilla Firefox for several years, but recently, what I type in Google or any window open a bookmark out backward for example ABCD appears as DCBA. I also have access to Internet Explorer, and it works perfectly. I don't know what I'm doing wrong, any suggestions? I use Windows 7 x 64 Edition Home Premium.
    Thank you

    Finally cracked. COR - el followed advice and new profile. It's early days, but everything seems to work well. Thank you all for your help and advice.
    Thank you, all have a good 2015

  • "To view this page, Firefox must send information that will repeat any action (for example, a search or order confirmation) that was carried out earlier."

    To view this page, Firefox must send information that will repeat any action (for example, a search or order confirmation) that was carried out earlier. Then I have to click on return or cancel. Then I have to click on return or cancel.

    How can I fix this automatically return?
    Please let me know!

    It is not possible.

    Do you use the back button to return to a previous page?

    You receive an alert to send POST data if you return to a page or refresh a page that was requested in advance from the server by submitting form via a (hidden) MESSAGE form data.
    Firefox can only make sure to get the same page send this POST form.
    Firefox doesn't know what it means shape data, so Firefox asks for confirmation before sending the form data so action can you take to repeat an action and buy another article or post a message once.
    One way to prevent this pop-up on the removal of the POST data is not to use the back button, but to open the links on a page that is requested from a server by sending a form with the date of the POST in a new tab (window) with a middle click or hold down the CTRL key and click the link.
    Then you can close the tab or window to go back.

  • On my iPod Nano 7th generation, there are some artists who are not listed, although their songs are on the iPod. For example, I have two Blue Oyster Cult songs on the iPod and they show, but Blue Oyster Cult is not listed under "artists".

    On my iPod nano, 7th generation, there are artists who are not in the list of "artists". For example, I have two Blue Oyster Cult songs appearing under "Songs", but Blue Oyster Cult is not indicated under "artists". Is it possible to have the COB and other artists who do not appear to show up under the "artists"?

    See Missing artist or Album not with others by the same artist.

    TT2

  • my keyboard has sometimes unresponsive, despite verified the above. Then it works again after I have shut down and restart my mac. is this normal? If this isn't the case, that due to an application? for example, I installed photoshop and use it all the ti

    Jin

    Sometimes, my keyboard stops responding, despite the checkist troubleshooting.

    Then it works again after I have shut down and restart my mac!

    is this normal? If this isn't the case, that due to an application? for example, I installed photoshop and use it all the time... also openoffice document prog...

    What else could be?

    I just replace the keyboard with a new one, but the problem persists.

    my mac has also been in mac repair and they found nothing wrong.

    Thank you!

    Please run and view a report of EtreCheck http://etrecheck.com/

Maybe you are looking for

  • How to change the default numbers indicated in the drop down tags

    I have more than 10 categories of beacon and wish that, when I go to these last tags or is it possible to add tags in the bookmark drop down?

  • My password has been changed against my will...

    Hello I had an account. The ID is: [passage removed for privacy] While it was open, I saw that the password has been changed against my will. I tried to reset it, it didn't work. I knew that the password is not even exist, which is weird. I used this

  • Big news for fans of bike e 1st gen

    The company will deploy the operating system upgraded to these phones with soak test, which means that the upgrade will be first held in a small group of users so that they can monitor performance data and comments from users over several days to mak

  • TDM and TDX reference error

    Hello I recently tried to open a .tdm file and I get an error that "fatal error (80): cannot open ' the file name and" (the system cannot find the file specified.)» I understand that the tdx file name must point to the tdx file, but the file that the

  • T61 is unable to sleep extended when the cover closed

    ThinkPad T617658 CTOT9300Windows XP SP3 This machine fails to Hibernate when closing the lid or pressing Fn - F12. "Preparation for the hibernation" appears on the screen indefinitely. I need to hold down the stop button to stop. This happens usually