cairo


How to fade out a Bitmap with gtkmm?


I use
Glib::RefPtr<Gdk::Pixbuf> image = Gdk::Pixbuf::create_from_file(sBitmapName);
Gdk::Cairo::set_source_pixbuf(cr, image, x, y);
to load and display a bitmap in a cairo context.
Is it possible to manipulate the pixels in the pixbuf once it is loaded?
I would like to fade out this image by decreasing the the alpha value of each pixel.
Or is there another possibility to fade out a pixmap?
Here is the solution i found:
with guchar *Gdk::Pixbuf::get_pixels() you get access to the pixels of the image. Any changes you make in this array are visible the next time the image is drawn:
int iW = m_image->get_width();
int iH = m_image->get_height();
guchar * pPixels = m_image->get_pixels();
int iNChannels = m_image->get_n_channels();
if (iNChannels == 4) {
for (int iY = 0; iY < iH; iY++) {
for (int iX = 0; iX < iW; iX++) {
int iOffset = iY*m_image->get_rowstride() + iX*iNChannels;
pPixels[iOffset+3] *= dRatio;
}
}
}
This fragment multiplies the alpha value of each pixel with real number thus changing the transparency. Repeatedly applying this leads to a fade-out effect

Related Links

Why does Cairo.set_source_rgb paint the whole canvas?
Howto sub class a Clutter.Actor (involves Cairo/Clutter.Canvas)
'CAIRO_GOBJECT_TYPE_SURFACE' undeclared
Drawing in a Clutter Texture with Cairo
can't render text in cairo
Why when painting one source to another am i getting the wrong colors
Can I automatically flow two font styles in a Pango Cairo Layout?
Cairo Radial Gradient
How to create gradient between two curves?
Cairo in scrollable drawing area
Can cairo load a PDF?
How to get Pango Cairo to word wrap properly?
Using named colors with Cairo graphics
How does compositor work on X?
Getting started with cairo using java bindings on windows
How to draw a curve without knowing 4 points?

Categories

HOME
arrays
spring
wxwidgets
qpython3
memory-leaks
search-engine
azureservicebus
value
quill
websphere-liberty
i2c
currency
goutte
deeplearning4j
dropbox
constructor
height
window
intellij-plugin
data-analysis
activesync
cloudflare
reduction
apache-karaf
arm-template
quartus
aptana
ng2-dragula
tweets
multiple-columns
google-ima
apply
tcpclient
profile
delete-file
fabric
pdfsharp
activepython
skmaps
branch
mef2
version-numbering
data-conversion
superscript
jackson-dataformat-csv
rowcount
skygear
stocks
fractals
canvasjs
swiftcharts
wfp
pmwiki
cross-entropy
rule
code-composer
bids
range-v3
windows-95
pagefile
execl
python-hypothesis
iron.io
verbose
inject
nofollow
boost-hana
string-parsing
scriptlet
financial
twgl.js
git-rebase
multinomial
prezto
coypu
line-numbers
grunt-contrib-concat
formvalidation-plugin
docopt
opensocial
db4o
mimosa
healthvault
sanitization
gamepad
angulartics
.net-cf-3.5
ienumerator
lame
iconv
xslkey
xml-libxml
usn
expression-evaluation
file-exists
nemerle
libavformat
loadui
grooveshark
front-controller
ajaxpro
dotproject

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App