Opened 19 years ago

Closed 19 years ago

#11 closed enhancement (fixed)

Implement alpha channel support for pixmaps (QPixmap)

Reported by: dmik Owned by: dmik
Priority: normal Milestone: qt-os2-3.3.1-rc07
Component: kernel Version:
Severity: normal Keywords: alpha channel blending QPixmap
Cc:

Description

We need to support the alpha channel in the QPixmap implementation, and correctly blend it when drawing pixmaps both to widgets and to other pixmaps.

Attachments (4)

alpha.zip (34.6 KB ) - added by dmik 19 years ago.
test case for alpha blending (updated)
alpha_2.png (175.3 KB ) - added by dmik 19 years ago.
how the testcase looks on OS/2
alpha_w.png (125.8 KB ) - added by dmik 19 years ago.
how the testcase looks on Win32
alpha_x.png (199.6 KB ) - added by dmik 19 years ago.
how the testcase looks on X11

Download all attachments as: .zip

Change History (8)

comment:1 by dmik, 19 years ago

Status: newassigned
Type: defectenhancement

comment:2 by anonymous, 19 years ago

I've just discovered that when you do bitBlt() of something directly to a pixmap, this pixmap's alpha channel will be untouched at all (no matter is it a simple mask or true alpha bits, and no matter does the source contain any alpha channel or not). So that bitBlt (dst_pm, src_pm) followed by drawPixmap (dst_pm) will produce visually different results comparing to drawPixmap (dst_pm) followed by drawPixmap (src_pm). This behavioer is definitely not what you could expect (because in both cases you just draw one pixmap over another to some painter), and more over, it is not clearly documented anywhere in Qt docs.

But for the sake of compatibility, I have to do the same in Qt/OS2. Keep in mind, however, that you can always correctly mix two pixmaps (in memory) by converting them to images and using bitBlt for QImage instead.

The testcase that demonstrates the above behavior is attached. Starting from the raw 3, first two columns contain results of mixing two pixmaps using bitBlt directly on them, last two columns contain results of converting the same pixmaps to QImages and using the QImage version of bitBlt. The difference can be clearly observed.

comment:3 by dmik, 19 years ago

anonymous above is me :)

comment:4 by dmik, 19 years ago

Resolution: fixed
Status: assignedclosed

Alpha blending is fully implemented now.

P.S. copyBlt() on Qt/Win32 is extremely buggy (because the destination pixmap is not dereferenced). You can see it using the updated alpha example (will attach).

by dmik, 19 years ago

Attachment: alpha.zip added

test case for alpha blending (updated)

by dmik, 19 years ago

Attachment: alpha_2.png added

how the testcase looks on OS/2

by dmik, 19 years ago

Attachment: alpha_w.png added

how the testcase looks on Win32

by dmik, 19 years ago

Attachment: alpha_x.png added

how the testcase looks on X11

Note: See TracTickets for help on using tickets.