Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: Emil_halim on May 14, 2007
-
Hi all
Does any one know a good algorithm of Magnification filter of Image processing ?
To make it more simple , I really need a very high quality Mag Filter algorithm, just like the flash movie player, the DirectX filter is poor when compared with flash player.
Any help appreciated .
-
Are you by chance referring to a radial blur?
I'm not quite sure what you're asking here.
-
Thanks Thygrion for your reply.
But not it is any blur effect , what I am asking for is , a Magnification algorithm that produce a good quality when we resize our Image.
When you have a small image and using DirectX Magnification filter the Image will has a poor Magnify , do the same thing with Flash Player you will notice that Flash Player give a very high quality Image.
So I just asking for a Magnification algorithm that similar to Flash Player.
-
Oh ok.
Well, this now becomes a matter of how things are rendered.
DirectX just stores images as just pixels, which is why you usually get a crappier resize.
What flash does is different entirely - flash is a vector-based program. So where DirectX draws lines of pixels, flash draws things such as ovals, rectangles, and lines.
You can see this in alot of flash cartoons - where all edges are well-rounded and don't "blur" with other pixels, because they aren't pixel-based. Vector graphics are object-based, and that's why flash has higher image quality.
Sorry if this is disappointing, but it's the truth.
Hope it helps.
-
I agree with Thygrion there.
Thinking about your problem though, I don't think that there will be much chance of getting the image quality you are after.
Maybe you will need to work with bigger textures, or as Thygrion suggested using some sort of blur routine to try and disguise the pixelation a little?
-
thanks Thygrion , Shocky.
Yah , it is clear now why Flash Player has more quality than DirectX.
any way I have found a better Magnification filter than DirectX , here is a link of it.
http://www.liimatta.org/fusion/filter/filter.html (http://www.liimatta.org/fusion/filter/filter.html)
It uses a bicubic algorithm , although it is not the same as Flash Player quality but it is better than DirectX.
BTW , where can I find the vector-based algorithm of ovals, rectangles, and lines?
-
Some of the routines in the framework here ;
http://dbfinteractive.com/index.php?topic=1455.0
Would be suitable for you to use. There is also a cubic spline routine in there which could be useful.
-
thanks Shocky. :)
Already using these code , it is very useful routines.
But I need more similar Flash Player algorithm.
Anyway thank you again for your help , have a nice time with Jacob Baby. :)
-
Can you post a side-by-side comparison picture of what you have and what you'd like? (bmp) There are tons of ways of producing the data to fill in the gaps between the real pixels.
Jim
-
Ok Jim, Here they are.
the poorest is DX one.
-
Looks like this image was originally made in flash -- two circles; a grey one and one on top of it with a gradient fill pattern. If you would like vector-based graphics you should research rendering methods of lines with variable width, ovals, rectangles, and 2D vector math in general for rotation, scaling, etc.
-
Yes , Thygrion , it is a Flash shape , I have searched for the vector graphics and found SVG (scalar vector graphics) but still search for open source SVG viewer to learn how it works.
-
Right, you're never going to find a bitmap scaling that will give you the result you want. But if you go here
http://en.wikipedia.org/wiki/Scalable_Vector_Graphics (http://en.wikipedia.org/wiki/Scalable_Vector_Graphics) there are lots of links at the end to SVG libraries which will definitely do what you want.
Jim
-
thanks Jim.
i have found a good library , it is Cairo , i will ues it.
-
Cairo does ovals / circles, true type fonts etc? :)
How easy is it to link and include something like that into a fb program?
-
Very very easy Shocky. :)
FreeBasic already has an example for Cairo Library , here it is
'' Cairo clock. Translated from the "C" example written by Writser Cleveringa
#include once "cairo/cairo.bi"
#include once "datetime.bi"
const SCR_W = 640
const SCR_H = 480
const PI = 3.14159265358979323846#
declare sub drawScreen()
'' main
screenRes SCR_W, SCR_H, 32
do
drawScreen()
sleep(1000)
loop until (len(inkey()) > 0)
'' Draws a clock on a normalized Cairo context
sub drawClock(cr as cairo_t ptr)
'' compute the angles for the indicators of our clock
dim as double minutes = Minute(Now()) * PI / 30
dim as double hours = Hour(Now()) * PI / 6
dim as double seconds = Second(Now()) * PI / 30
'' draw the entire context white.
cairo_set_source_rgba(cr, 1, 1, 1, 1)
cairo_paint(cr)
'' who doesn't want all those nice line settings :)
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)
cairo_set_line_width(cr, 0.1)
'' translate to the center of the rendering context and draw a black
'' clock outline
cairo_set_source_rgba(cr, 0, 0, 0, 1)
cairo_translate(cr, 0.5, 0.5)
cairo_arc(cr, 0, 0, 0.4, 0, PI * 2)
cairo_stroke(cr)
'' draw a white dot on the current second.
cairo_set_source_rgba(cr, 1, 1, 1, 0.6)
cairo_arc(cr, sin(seconds) * 0.4, -cos(seconds) * 0.4, 0.05, 0, PI * 2)
cairo_fill(cr)
'' draw the minutes indicator
cairo_set_source_rgba(cr, 0.2, 0.2, 1, 0.6)
cairo_move_to(cr, 0, 0)
cairo_line_to(cr, sin(minutes) * 0.4, -cos(minutes) * 0.4)
cairo_stroke(cr)
'' draw the hours indicator
cairo_move_to(cr, 0, 0)
cairo_line_to(cr, sin(hours) * 0.2, -cos(hours) * 0.2)
cairo_stroke(cr)
end sub
'' Shows how to draw with Cairo
sub drawScreen()
screenLock
dim as cairo_surface_t ptr cairo_surface = _
cairo_image_surface_create_for_data(screenPtr, _
CAIRO_FORMAT_ARGB32, SCR_W, _
SCR_H, SCR_W*len(integer))
'' Create a cairo drawing context, normalize it and draw a clock.
'' Delete the context afterwards.
dim as cairo_t ptr cr = cairo_create(cairo_surface)
cairo_scale(cr, SCR_W, SCR_H)
drawClock(cr)
cairo_destroy(cr)
screenUnlock
end sub
I am still tring to make a static cairo library.
-
Really cool dude that you're getting on with this!
-
Thanks Thygrion , appreciate your help. :)