Main index > Python programming > Filters don't work if image height is 1

By ZeroDivide (Desklet Author), on Fri Mar 25 18:34:53 2005: Filters don't work if image height is 1.

Filters don't seem to work on images with a height of 1. I'm not sure if this is a adesklets or imlib2 thing.

example code:

Code:

#! /usr/bin/env python
from adesklets.commands import *
from time import sleep

context_set_color(255,255,255,255)

#create image with a height of 1 and apply red filter
image_h1=create_image(1,1)
context_set_image(image_h1)
image_fill_rectangle(0,0,1,1)
apply_filter('tint(alpha=255,red=255,green=0,blue=0);')

#create image with a height of 2 and apply blue filter
image_h2=create_image(1,2)
context_set_image(image_h2)
image_fill_rectangle(0,0,1,2)
apply_filter('tint(alpha=255,red=0,green=0,blue=255);')

#setup window
window_resize(50,100)
window_show()

#scale each image over half of the window
context_set_image(0)
blend_image_onto_image(image_h1,1,0,0,1,1,
                                  0,0,50,50)
blend_image_onto_image(image_h2,1,0,0,1,2,
                                  0,50,50,50)
sleep(99999)

By syfou (Core Developer & Desklet Author), on Fri Mar 25 19:14:52 2005.

Yes... Well, it depens what Imlib2 you use. I am on cvs now (extracted last week), and the problem doesn't manifest itself. I reverted to official Imlib2 package, and I saw it.

Internally, the tint filter (src/modules/filters/colormap.c) just creates and applies a color modifier to the image, and there is a small discrepancy in the way imlib_apply_color_modifier_to_rectangle() gets called on some versions.

Alternatively, if you really need this, you could do:

Code:


from adesklets.commands import *
from signal import pause

context_set_color(255,255,255,255)

#create a full white to blue channel only
#WARNING: I did this for the sake of simplicity:
#a true tint filter should also take care of others components.
context_set_color_modifier(create_color_modifier())
set_color_modifier_value(CHANNEL_RED,255,0)
set_color_modifier_value(CHANNEL_GREEN,255,0)

#create image with a height of 1 and apply color modifier
image_h1=create_image(1,1)
context_set_image(image_h1)
image_fill_rectangle(0,0,1,1)
apply_color_modifier()

#create image with a height of 2 and apply color modifier
image_h2=create_image(1,2)
context_set_image(image_h2)
image_fill_rectangle(0,0,1,2)
apply_color_modifier()

#setup window
window_reset(1)
window_resize(50,100)
window_show()

#scale each image over half of the window
context_set_image(0)
blend_image_onto_image(image_h1,1,0,0,1,1,
                                  0,0,50,50)
blend_image_onto_image(image_h2,1,0,0,1,2,
                                  0,50,50,50)
pause()

By ZeroDivide (Desklet Author), on Fri Mar 25 23:17:13 2005.

Thanks for checking this out..
I think i'll stick to using images with a height of at least 2 for now.

ZeroDivide


adesklets is proud to be hosted on:

SourceForge.net Logo

Back to adesklets.sf.net.