[cairo] scale without bluring

Vladimir Vukicevic vladimir at pobox.com
Sun Sep 28 17:19:09 PDT 2008


Right, that's what you end up with with bilinear, like I mentioned.   
Is there any graphics toolkit that gives you the effect you're looking  
for?  Nearest neighbour is probably close -- just set  
CAIRO_FILTER_FAST before you scale the surface, e.g.  
cairo_set_source_surface(...); cairo_pattern_set_filter  
(cairo_get_source(cr), CAIRO_FILTER_FAST);

    - Vlad

On Sep 28, 2008, at 3:58 PM, Michael Gurnett wrote:

> This is what I'm getting
>
>
> ----- Original Message ----- From: "Antoine Azar" <cairo at antoineazar.com 
> >
> To: "'Michael Gurnett'" <gurnett at glocalnet.net>; <cairo at cairographics.org 
> >
> Sent: Monday, September 29, 2008 12:31 AM
> Subject: RE: [cairo] scale without bluring
>
>
>> Vlad's correct, I also tried about every mode in Photoshop (which  
>> has great
>> image scaling) and I get horrible results in every case. Check out  
>> the
>> attached pictures for 3 different modes. Let us know if this is  
>> similar to
>> what you're seeing with Cairo.
>>
>> I would recommend not scaling your image 99% but rather resampling  
>> your
>> data. Although that might not work with your CPU and memory  
>> requirements.
>>
>> Otherwise, you could just append your new data to your original image
>> (unscaled), and then rescaling to your desired size. You'd have good
>> quality, but your original image would keep on growing in size in  
>> memory.
>>
>> Cheers,
>> Antoine
>>
>>
>> -----Original Message-----
>> From: cairo-bounces at cairographics.org
>> [mailto:cairo-bounces at cairographics.org] On Behalf Of Michael Gurnett
>> Sent: Sunday, September 28, 2008 6:13 PM
>> To: cairo at cairographics.org
>> Subject: Re: [cairo] scale without bluring
>>
>> The data is such that individual spikes are not an issue. The graph  
>> is
>> basically there so that the user can see the general behaviour of the
>> currents and voltages of the machines. For a more detailed view the  
>> user can
>>
>> monitor log files that save every second over a 72hr period (alot  
>> of data).
>> I have a moving data window that just shows the last lot of data,  
>> but users
>> do like to see entire data window as well. With the approach as was
>> attempting here I get a constant behaviour in regards to how long  
>> the data
>> processing takes and also a fairly small use of memory..
>>
>> Michael
>>
>>
>> ----- Original Message ----- From: "Vladimir Vukicevic" <vladimir at pobox.com 
>> >
>> To: "Michael Gurnett" <gurnett at glocalnet.net>
>> Cc: <cairo at cairographics.org>
>> Sent: Sunday, September 28, 2008 11:57 PM
>> Subject: Re: [cairo] scale without bluring
>>
>>
>>>
>>> On Sep 28, 2008, at 2:41 PM, Michael Gurnett wrote:
>>>
>>>>> I have to copy the old picture, To much data to redraw all over   
>>>>> again.
>>>>> I'm
>>>>> scaling down along the x-axis adding a a bit more data and then  
>>>>> scaling
>>
>>>>> and
>>>>> adding data and so on.
>>>>
>>>
>>> That's never going to give you a reasonable result, though -- you're
>>> filtering the image each time you add data, and losing tons of data.
>>> With either nearest neighbour or bilinear filtering, there'll be
>>> something wrong... with nearest, it'll easily hide big spikes in  
>>> your
>>> data graph, if that column happens to be skipped due to  
>>> rounding.   With
>>> bilinear, it'll just blur your graph to nothing useful.
>>>
>>>> Should I be using patterns instead. I've been using
>>>>
>>>>   cairo_set_source_surface (cr_buffer, surface_current, 0, 0);
>>>> cairo_paint(cr_buffer);
>>>
>>> Shouldn't matter.  You should probably rethink the way that you're
>>> rendering data.. for example, instead of rescaling for each data   
>>> point,
>>> add in a new chunk at a time... e.g. maybe 25% of your total   
>>> width --
>>> when you fill it up, compute averages of the previously  received  
>>> data and
>>
>>> draw it into the first 75%, then start filling up  the new 25%  
>>> using the
>>> same average window.
>>>
>>>   - Vlad
>>>
>>>> ----- Original Message -----
>>>> From: "Chris Wilson" <chris at chris-wilson.co.uk>
>>>> To: "Michael Gurnett" <gurnett at glocalnet.net>
>>>> Cc: <cairo at cairographics.org>
>>>> Sent: Sunday, September 28, 2008 10:47 PM
>>>> Subject: Re: [cairo] scale without bluring
>>>>
>>>>
>>>>> On Sun, 2008-09-28 at 21:32 +0200, Michael Gurnett wrote:
>>>>>> Have been struggleing with this for a while now and could do  
>>>>>> with some
>>>>>> pointers. I rescaling a graph by 0.99 over and over again in  
>>>>>> the x
>>>>>> directions. When I do this the image blurs out and in the end  
>>>>>> the data
>>>>>> is lossed. I tried using StretchBlt but this just not seem to be
>>>>>> compatible with the format of the cr. It doesn't blur but i  
>>>>>> doesn't
>>>>>> scale correctly. I've tried turning off antialising but that  
>>>>>> does  not
>>>>>> seem to help either. Any hints on how to scale without  
>>>>>> blurring.Is
>>>>>> there a StretchBlt equivalent in cairo that I have missed?
>>>>>
>>>>> You haven't mentioned it, so I assume you've not tried setting
>>>>> CAIRO_FILTER_NEAREST on the source pattern. Although I have to  
>>>>> ask, why
>>>>> are you rescaling the graph and not redrawing?
>>>>>
>>>>> -- 
>>>>> Chris Wilson
>>>> _______________________________________________
>>>> cairo mailing list
>>>> cairo at cairographics.org
>>>> http://lists.cairographics.org/mailman/listinfo/cairo
>>
>> _______________________________________________
>> cairo mailing list
>> cairo at cairographics.org
>> http://lists.cairographics.org/mailman/listinfo/cairo
> <graph.jpg>_______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo



More information about the cairo mailing list