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
Contributor
chris_chrono
Posts: 10
Registered: ‎01-21-2013
My Device: bb10 alpha

Re: Insert transparent QImage to ImageView

Hi mnosov, i have tried your solution, and the result is still the same, the transparent area is still white at the ImageView,
As for the QImage, the transparent area is correct because i use it for other part with qpainter.

so still the problem is how to convert transparent image correctly from QImage to ImageView

any other trick?
Contributor
mnosov
Posts: 15
Registered: ‎10-25-2012
My Device: Dev Alpha B

Re: Insert transparent QImage to ImageView

In case that everything works on my side, I'd suggest the following:

 

1. Did you really converted your with QImage::convertToFormat(QImage::Format_ARGB32_Premultiplied)?

2. As far as I remember I had some problems with PNG images which had some 'background color' property. I'm not sure, what is it, but if I uncheck "Save background color" option in GIMP - then resulting PNG file can be read and displayed without any problems.

3. You can check returned value of qAlpha(QImage::smileytongue:ixel(x,y)) - is it really 0 (fully transparent)?

Developer
Dredvard
Posts: 160
Registered: ‎01-27-2012
My Device: Playbook

Re: Insert transparent QImage to ImageView

As long as its ARGB32_premultiplied, this is how I did it:

void imageScribble::updateImage() {

    const QImage finalImage = m_qimage.rgbSwapped();

    const bb::ImageData imageData = bb::ImageData::fromPixels(finalImage.bits(),
//            bb::PixelFormat::RGBX, finalImage.width(), finalImage.height(),
            bb::PixelFormat::RGBA_Premultiplied, finalImage.width(), finalImage.height(),
            finalImage.bytesPerLine());

    m_image = bb::cascades::Image(imageData);
    emit imageChanged();
}

 That works fine for me.

---
If you find my post helpful please "like" it and "accept as a solution"
New Contributor
i2mobi
Posts: 2
Registered: ‎01-27-2013
My Device: bb10

Re: Insert transparent QImage to ImageView

hi,mnosov:
I also used these codes in my project, but met a build error as below:
Description Resource Path Location Type
make: *** [Simulator-Debug] Error 2 Sketch C/C++ Problem
make[1]: *** [debug] Error 2 Sketch C/C++ Problem
make[2]: *** [o-g/Sketch] Error 1 Sketch C/C++ Problem

Did you meet this error?
Contributor
mnosov
Posts: 15
Registered: ‎10-25-2012
My Device: Dev Alpha B

Re: Insert transparent QImage to ImageView

hi, i2mobi,

 

No, I didn't see such error ever. Maybe this is because i didn't try this on simulator - I'm using "BB10 Alpha B" device for testing

Contributor
chris_chrono
Posts: 10
Registered: ‎01-21-2013
My Device: bb10 alpha

Re: Insert transparent QImage to ImageView

i have tried mnosov's solution, but i still got the white area for the transparent area, so that solution is also not solving the problem. it seems that the ImageData library is still need to be updated.

as for oliver_kranz solution, i think you didn't read the problem correctly, the problem is "how to insert the transparent image from QImage to ImageView, because with the current sample from blackberry, the transparent area will be appeared as white area"
Contributor
mnosov
Posts: 15
Registered: ‎10-25-2012
My Device: Dev Alpha B

Re: Insert transparent QImage to ImageView

To chris_chrono,

 

I've just uploaded an example of how i did it here: https://github.com/mnosov/testroundprogress

You can try this example and check if it works for you

Contributor
chris_chrono
Posts: 10
Registered: ‎01-21-2013
My Device: bb10 alpha

Re: Insert transparent QImage to ImageView

Hi mnosov, it seems that my source png file, have the setting that you mention before that keep the background color, this might be the one that create the problem with the convertion to ImageData, because when i use your "outer_progress_bar.png", the transparent area apprears correctly.

the problem is, i cannot control the source png files, because it was user generated content, that is why i need to know a sure way to convert it without making the transparent area into white area.
Contributor
mnosov
Posts: 15
Registered: ‎10-25-2012
My Device: Dev Alpha B

Re: Insert transparent QImage to ImageView

Can you try to replace my outer_progress_bar.png with your file and try it on my example? If problem exists, can you share the example png file?

New Contributor
i2mobi
Posts: 2
Registered: ‎01-27-2013
My Device: bb10

Re: Insert transparent QImage to ImageView

thanks your replay