Page 1 of 2

bitmap transparency setting

Posted: Sat Sep 20, 2014 11:48 am
by tester
Is there a way to regulate transparency of loaded bitmap? Via ruby perhaps?

Or going a little bit further - how to perform math (old paintshop-like style: average, multiply, difference, and, or, etc.) operations on same sized bitmaps?

Basically I'd like to make something that operates on multiple bitmaps at the same time, with simple on/off switching and reloading what I want. Yet another mad science experiment. :-)

Re: bitmap transparency setting

Posted: Sat Sep 20, 2014 2:53 pm
by Exo
The only feasible way to modify bitmaps is via the DLL component. Ruby would be way to slow.

There us an example Here of modifying the transparency if a bitmap.

It is all pretty tricky though because you have to work directly with a BYTE array.

Re: bitmap transparency setting

Posted: Sat Sep 20, 2014 2:58 pm
by tester
Maybe it will be not that bad? I mean - It's going to be rater set-once situation, depending on how many slots are in use, plus - graphics will be rather under 1000px sizes. By slow you mean seconds, tens of seconds, minutes?

Re: bitmap transparency setting

Posted: Sat Sep 20, 2014 3:49 pm
by Exo
Actually it is not even possible in Ruby because there is no Bitmap class, that is the reason it is passed from outside only. The bitmap that is passed cannot be modified.

You could try using the primitive "getPixel" and "setPixel" but this will be quite slow maybe it will be ok but the UI will become unresponsive if it takes to long.

Re: bitmap transparency setting

Posted: Sat Sep 20, 2014 4:23 pm
by tester
I see in manual, that there is transparency setting for bitmap in ruby?

http://www.dsprobotics.com/Files/V3/User%20Guide.pdf
site: 167

Manipulating transparency should do the "average" function, and maybe I don't need anything more.

Re: bitmap transparency setting

Posted: Sat Sep 20, 2014 4:31 pm
by Exo
I never noticed that, that should work fine then for transparency and should be fast too because it is a built in.

Re: bitmap transparency setting

Posted: Sat Sep 20, 2014 4:33 pm
by tester
Some other functions/adjustements can be probably done by backgrounding or foregrounding white/black layer.

Re: bitmap transparency setting

Posted: Sat Sep 20, 2014 5:35 pm
by tester
Coult you post an example on how to use it with transparency?

But also, so that the bitmap follows area size (is rescaled to fit the area as you rescale the gui by dragging it).

Re: bitmap transparency setting

Posted: Sun Sep 21, 2014 12:07 pm
by tester
I think I found it.

Re: bitmap transparency setting

Posted: Sun Sep 21, 2014 12:30 pm
by tester
...and how/where to include this?

Bitmap Rendering Options
If you are drawing a bitmap into a rectangle that is a different size then you can choose how to render
that bitmap by setting the interpolation mode. This is done using the following View method:
setInterpolationMode
mode
This takes either an integer (0-7) or one of the following strings:
"low","high","bilinear","bicubic","nearest","hqbilinear","hqbicubic"