File: README.PORTING

package info (click to toggle)
qimageblitz 1:0.0.6-5
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 696 kB
  • ctags: 434
  • sloc: cpp: 5,803; asm: 574; makefile: 11
file content (129 lines) | stat: -rw-r--r-- 3,810 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
I. Introduction.

Since most people using this are going to be porting code from KImageEffect
I've written a small porting guide to help you out. This is broken into two
main sections: "Depreciated And Removed Items", which describes methods that
have been removed, and "Changed Methods And Parameters", which describes 
methods that are still there but have changed names or parameters.

This document just describes API changes. It does not discuss if the actual 
method's algorithm has changed. Many have so may give different results. For a
general overview of some of these changes see README.BLITZ.

Daniel M. Duley <daniel.duley@verizon.net>

II. Depreciated And Removed Items.

*
* rotate()
*
QImage::transformed() now has efficient special cases to handle right angles 
and performance should be fine. Use that instead.

*
* hash()
* shade()
* solarize()
*
These were removed because they either weren't being used much, were expensive,
or in the case of solarize rather stupid, (at least how I coded it ;-).

*
* blend():
* blendOnLower():
* flatten():
* modulate():
* selectedImage():
*
I suspect the removal of these methods are probably what is going to cause a 
the most porting problems. They were primarily used to generate special image 
overlays and highlights. 

The problem with them is they are a huge amount of unmaintained code and now 
QPainter has very well designed alphablending and raster operations that make
them obsolete. Your better off using QPainter.

If your like me you might first balk at doing this because it seems like
overkill to use QPainter just to do a highlight, but it's now really efficient 
at blending and raster ops. If you don't believe me look at Qt's 
src/gui/painting/qdrawutil.* and qpaintengine_raster. It's really rather 
amazing at how optimized it is, at least to me >:)

Here is a little example to get you started. This will highlight an image 
contained in "image" with a blue overlay while still retaining the original 
alpha channel:

// Upgrade if needed for alphablending
if(image.format() != QImage::Format_ARGB32_Premultiplied &&
    image.format() != QImage::Format_ARGB32)
      image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);

// Draw our overlay
QPainter p;
p.begin(&image);
// Keep original image alpha channel
p.setCompositionMode(QPainter::CompositionMode_SourceAtop);
// Replace this color with your overlay's color and alpha value
p.fillRect(image.rect(), QColor(0, 0, 255, 64));
// Done
p.end();

To do a pixmap is very similiar and is what KPixmapEffect::selectedPixmap()
used to do when updated to Qt4, (thanks to Fredrik).

III. Changed Methods And Parameters.

*
* toGray()
*
Changed to grayscale() because the meaning of the bool parameter has changed.

*
* contrast()
* contrastHSV()
*
There are no longer two contrast methods, just contrast(), and it takes the
same parameters that contrastHSV() used to.

*
* charcoal()
*
No longer takes a radius or sigma.

*
* edge()
*
The default edge algorithm has changed and no longer takes a radius parameter. 
For the old behavior use convolveEdge() instead.

*
* blur()
* 
The default blur algorithm has changed and now just takes an integer radius. 
For the old behavior use gaussianBlur() instead.

*
* oilPaint()
* oilPaintConvolve()
*
There is now only the oilPaint() method since we now have very efficient 
convolution. It takes the same parameters that oilPaintConvolve() used to.

*
* sharpen()
*
The sharpen method that took a single factor parameter has been depreciated 
and removed. Use the other convolve-based sharpen() that takes a radius and 
sigma instead.

*
* threshold()
*
Now takes a channel enum to threshold as well as "on" and "off" colors.
The default values are the same.

*
* channelIntensity()
*
Shares the same enum as threshold().