Page 1 of 1

Bitmap knobs strange scaling/fuzziness

Posted: Wed Nov 12, 2014 4:58 pm
by natbuk
Hi.

Hoping one of you gurus can help.

Just trying out Flowstone - downloaded it yesterday. I like the potential I'm seeing so far, and was close to buying it, but having some bother with bitmap-blitted knobs.

I have 31 of, 64x64 knob pics made in a vertically joined, rotating, sequence made with Knobman. They look fine in gfx package, and fine if I draw the whole thing statically in Flowstone (i.e. the long strip).

when I load them in as a bitmap, I then use the following to attempt to make a rotating knob:

knobNumPics = 31
knobHeight = ( (@picKnob.height/knobNumPics)).to_int
knobHeight = 64
cell = ((knobNumPics - 0.45 ) * @meterVal ).to_int

srcRect = [0,bmpVertStart,64, 64 ]
output 1, cell

v.drawBitmapSection @picKnob, srcRect,[0,0, 20, 20 ]

This works, in that a fuzzy version of the knob is drawn, and does rotate as expected, but (seemingly) due to the stupid grid-based scaling of srcRect/drawBitmapSection compared with drawBitmap, the pixel-to-pixel mapping I was expecting is lost.

Is this just a (severe) limitation or is there something I've misunderstood? (hoping the latter).

I guess I could load in 31 separate bitmaps (groan) and make it work that way.

What is it with this grid-based scaling thing and why is it there? Just seems silly when dealing with bitmaps.

Many thanks in advance

n.

Re: Bitmap knobs strange scaling/fuzziness

Posted: Wed Nov 12, 2014 7:14 pm
by KG_is_back
Fuzziness may happen because of interpolation, if the bitmap is not perfectly aligned with screen pixels. Normally Grid in FS is 8*8 pixels. Check if the X and Y offset of the bitmap is integer when you multiply it by 8.

Re: Bitmap knobs strange scaling/fuzziness

Posted: Wed Nov 12, 2014 8:21 pm
by Exo
Hi natbuk, welcome!

Try scaling up in multiples of 8, for example 16 or 24.
Also the grid pixel size can be changed in the options if you like, although I have never felt a need to do that.

Re: Bitmap knobs strange scaling/fuzziness

Posted: Thu Nov 13, 2014 12:18 am
by tulamide
natbuk wrote:Hi.

Hoping one of you gurus can help.

Just trying out Flowstone - downloaded it yesterday. I like the potential I'm seeing so far, and was close to buying it, but having some bother with bitmap-blitted knobs.

I have 31 of, 64x64 knob pics made in a vertically joined, rotating, sequence made with Knobman. They look fine in gfx package, and fine if I draw the whole thing statically in Flowstone (i.e. the long strip).

when I load them in as a bitmap, I then use the following to attempt to make a rotating knob:

knobNumPics = 31
knobHeight = ( (@picKnob.height/knobNumPics)).to_int
knobHeight = 64
cell = ((knobNumPics - 0.45 ) * @meterVal ).to_int

srcRect = [0,bmpVertStart,64, 64 ]
output 1, cell

v.drawBitmapSection @picKnob, srcRect,[0,0, 20, 20 ]

This works, in that a fuzzy version of the knob is drawn, and does rotate as expected, but (seemingly) due to the stupid grid-based scaling of srcRect/drawBitmapSection compared with drawBitmap, the pixel-to-pixel mapping I was expecting is lost.

Is this just a (severe) limitation or is there something I've misunderstood? (hoping the latter).

I guess I could load in 31 separate bitmaps (groan) and make it work that way.

What is it with this grid-based scaling thing and why is it there? Just seems silly when dealing with bitmaps.

Many thanks in advance

n.

Just a quick visit, because I don't have much time. There are some issues with the code you posted.

Code: Select all

knobHeight =  (  (@picKnob.height/knobNumPics)).to_int
knobHeight = 64
The second assignment overwrites the first. If you know that the height is 64, you don't need the first line. If you don't know, you have to get rid of the second. Also, the first one uses grid units (.height), and I assume the second one pixel values.

Code: Select all

cell = ((knobNumPics - 0.45 ) * @meterVal ).to_int
What's @meterVal? Why are you outputting cell?

Code: Select all

v.drawBitmapSection @picKnob, srcRect,[0,0, 20, 20   ]
Here you're drawing (converted to pixels, assuming default grid of 8 px per grid unit) from the bitmap the section 0, bmpVertStart * 8, 512, 512 to 0, 0, 160, 160
Is this really what you wanted?

In general, to convert to pixels, if you prefer calculating them instead of grid units, there are the view properties 'gridStep' and 'defaultGridStep'. The first one returns the current grid step (= grid step value with respect to the current zoom level), the second one the grid step at standard zoom (which is 8 pixels, if you didn't change it)
Also, the bitmap object alternatively offers size values in pixels. Instead of .width, .height just use .widthPixels, .heightPixels.

Converting pixel to grid (ignoring zoom):
bitmap.widthPixels / v.defaultGridStep

Converting grid to pixel(ignoring zoom):
bitmap.width * v.defaultGridStep

Tell me if something's unclear.

Re: Bitmap knobs strange scaling/fuzziness

Posted: Thu Nov 13, 2014 11:38 am
by Nubeat7
i've tested the knobs with jknobmaker once, works all fine, you also need to take care of the startangles, watch this thread..

viewtopic.php?f=3&t=1129