[haiku-3rdparty-dev] Re: Advice on using lipwarpsharp for my Cover Art Display Plugin for CL-Amp

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Thu, 07 Jan 2010 13:42:34 +0100

Hi,

On 2010-01-07 at 11:58:42 [+0100], hey68 you <hey68you@xxxxxxxxx> wrote:
> Here is the code snippet that I need to modify to use smooth scaling:
> 
>         BBitmap* background =
> BTranslationUtils::GetBitmap(this->strImageFile);
>         BRect rectImage = background->Bounds();
> 
>         if (bPREFS_SCALE_IMAGE)
>         {
> 
> this->SetViewBitmap(background,rectImage,BRect(0,0,SCALED_WIN_SIZE,SCALED_
> WIN_SIZE));
>             Window()->ResizeTo(SCALED_WIN_SIZE,SCALED_WIN_SIZE);
>         }

If you just want to do smooth scaling, the Haiku app_server already 
supports that internally. Just pass B_FILTER_BITMAP_BILINEAR as the bitmap 
rendering options. If I remember correctly that I added the feature to 
allow B_FILTER_BITMAP_BILINEAR to be part of the options passed to 
SetViewBitmap(), then this should work:

SetViewBitmap(background, rectImage,
    BRect(0, 0, SCALED_WIN_SIZE, SCALED_WIN_SIZE),
    B_TILE_BITMAP | B_FILTER_BITMAP_BILINEAR);

If this does not work, then you need to use DrawBitmap(). Forget about 
SetViewBitmap() and just implement Draw() and use DrawBitmap():

DrawBitmap(background, background->Bounds(), Bounds(),
    B_FILTER_BITMAP_BILINEAR);

That will most definitely work.


If you indeed want to use image sharpening, like what libwarpsharp offers, 
then you need to use that. AGG does not offer image sharpening, just smooth 
scaling, so it wouldn't offer you anything over what the Haiku app_server 
already can do for you. However, since the album cover art is often not 
very high resolution, I doubt that libwarpsharp will generate good looking 
up-scales.

Hope this helps & best regards,
-Stephan

Other related posts: