Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Re: [MBS] pictureMBS.Scale (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] WindowsMidiMBS.Idle vs WindowsMidiInputMBS.Idle
Next thread: [MBS] pdf signature


[MBS] MBS 7.5 with RB2010r4.1   -   Garth Hjelte
  Re: [MBS] pictureMBS.Scale   -   Julia Truchsess
   Re: [MBS] pictureMBS.Scale   -   Christian Schmitz
    Re: [MBS] pictureMBS.Scale   -   Julia Truchsess
    [MBS] pictureMBS.Scale   -   Julia Truchsess
     Re: [MBS] pictureMBS.Scale   -   Christian Schmitz
    [MBS] pictureMBS.Scale   -   Julia Truchsess
     Re: [MBS] pictureMBS.Scale   -   Christian Schmitz

Re: [MBS] pictureMBS.Scale
Date: 06.01.18 16:33 (Sat, 6 Jan 2018 15:33:03 +0000)
From: Julia Truchsess
So is there a way with MBS plugins to scale a PNG with choice of resampling algorithm while retaining transparency/alpha?

Thanks,
Julia

Date: Thu, 4 Jan 2018 21:20:29 +0100
From: Christian Schmitz <<email address removed><mailto:<email address removed>><mailto:<email address removed>>>
Subject: Re: [MBS] pictureMBS.Scale

Am 04.01.2018 um 19:27 schrieb Julia Truchsess <<email address removed><mailto:<email address removed>><mailto:<email address removed>>>:
I???m trying to scale a PNG using pictureMBS.scale. The scaling looks nice but I lose the background transparency. Which ImageFormat do I need to use?

What do you want to do?
Scale picture with alpha?

Why do you use PictureMBS here?

I want to scale a PNG with good smoothing (e.g. Cubic or Mitchell algorithm) while retaining transparency/alpha. Simply redrawing into a graphics object at a new size per your example results in a poor quality image. I used PictureMBS because it???s the first class I found that offers smoothing.

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] pictureMBS.Scale
Date: 06.01.18 17:05 (Sat, 6 Jan 2018 17:05:50 +0100)
From: Christian Schmitz

> Am 06.01.2018 um 16:33 schrieb Julia Truchsess <<email address removed>>:
>
> So is there a way with MBS plugins to scale a PNG with choice of resampling algorithm while retaining transparency/alpha?
>

It’s on the todo list to be checked…
I may need another function to help, not sure.

Sincerely
Christian

Re: [MBS] pictureMBS.Scale
Date: 07.01.18 13:56 (Sun, 7 Jan 2018 12:56:29 +0000)
From: Julia Truchsess
OK, thanks. Maybe in the meantime I can extract the mask, scale the mask separately, then combine the mask with the scaled image using existing functions - would that work?

Julia

Date: Sat, 6 Jan 2018 17:05:50 +0100
From: Christian Schmitz <<email address removed><mailto:<email address removed>>>
Subject: Re: [MBS] pictureMBS.Scale
To: MBS-Plugin-Liste Plugin List <<email address removed><mailto:<email address removed>>>
Message-ID:
<<email address removed><mailto:<email address removed>>>
Content-Type: text/plain; charset=utf-8

Am 06.01.2018 um 16:33 schrieb Julia Truchsess <<email address removed><mailto:<email address removed>>>:
So is there a way with MBS plugins to scale a PNG with choice of resampling algorithm while retaining transparency/alpha?

It’s on the todo list to be checked…
I may need another function to help, not sure.

Sincerely
Christian

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

[MBS] pictureMBS.Scale
Date: 05.01.18 14:56 (Fri, 5 Jan 2018 13:56:12 +0000)
From: Julia Truchsess

Date: Thu, 4 Jan 2018 21:20:29 +0100
From: Christian Schmitz <<email address removed><mailto:<email address removed>>>
Subject: Re: [MBS] pictureMBS.Scale

Am 04.01.2018 um 19:27 schrieb Julia Truchsess <<email address removed><mailto:<email address removed>>>:
I’m trying to scale a PNG using pictureMBS.scale. The scaling looks nice but I lose the background transparency. Which ImageFormat do I need to use?

What do you want to do?
Scale picture with alpha?

Why do you use PictureMBS here?

I want to scale a PNG with good smoothing (e.g. Cubic or Mitchell algorithm) while retaining transparency/alpha. Simply redrawing into a graphics object at a new size per your example results in a poor quality image. I used PictureMBS because it’s the first class I found that offers smoothing.

Julia
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] pictureMBS.Scale
Date: 07.01.18 13:02 (Sun, 7 Jan 2018 13:02:02 +0100)
From: Christian Schmitz

> Am 05.01.2018 um 14:56 schrieb Julia Truchsess <<email address removed>>:
>
> I want to scale a PNG with good smoothing (e.g. Cubic or Mitchell algorithm) while retaining transparency/alpha. Simply redrawing into a graphics object at a new size per your example results in a poor quality image. I used PictureMBS because it’s the first class I found that offers smoothing.
>

Ihis seems to work here:

dim f as FolderItem = GetFolderItem("test.png")
dim p as Picture = Picture.Open(f)

if p.Type <> Picture.Types.MutableBitmap then
// make a copy, so we get a bitmap picture
dim t as new Picture(p.Width, p.Height)
t.Graphics.DrawPicture p, 0, 0, p.Width, p.Height, 0, 0, p.Width, p.Height
p = t
end if

dim destWidth as integer = p.width*2
dim destHeight as integer = p.Height*2

dim o as new Picture(destWidth, destHeight)

dim pi as new PictureMBS(p, true)
dim po as new PictureMBS(o, true)
dim r as Boolean = po.Scale(pi, nil, pi.ScaleCubic, destWidth, destHeight)

f = SpecialFolder.Desktop.Child("output.png")
o.Save(f, o.SaveAsPNG)

Can you try?

Sincerely
Christian

[MBS] pictureMBS.Scale
Date: 04.01.18 19:27 (Thu, 4 Jan 2018 18:27:25 +0000)
From: Julia Truchsess
I’m trying to scale a PNG using pictureMBS.scale. The scaling looks nice but I lose the background transparency. Which ImageFormat do I need to use? Or am I using the wrong method?

dim pic As new PictureMBS(myPNG)
dim temp As new PictureMBS(me.Width,me.Height,PictureMBS.ImageFormatRGBA)
call temp.Scale(pic, nil, 7, me.Width, me.Height) // 7 is cubic mode

Are there class constants for the mode or do I have to remember the values?

Thanks,
Julia
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] pictureMBS.Scale
Date: 04.01.18 21:20 (Thu, 4 Jan 2018 21:20:29 +0100)
From: Christian Schmitz

> Am 04.01.2018 um 19:27 schrieb Julia Truchsess <<email address removed>>:
>
> I’m trying to scale a PNG using pictureMBS.scale. The scaling looks nice but I lose the background transparency. Which ImageFormat do I need to use?

What do you want to do?
Scale picture with alpha?

Why do you use PictureMBS here?

For scale with mask, you can do this:

Function ProportionalScaled(extends pic as Picture, Width as Integer, Height as Integer) As Picture
// Calculate scale factor

dim faktor as Double = min( Height / Pic.Height, Width / Pic.Width)

// Calculate new size
dim w as Integer = Pic.Width * faktor
dim h as Integer = Pic.Height * faktor

// create new picture
dim NewPic as new Picture(w, h)

// draw picture in the new size
NewPic.Graphics.DrawPicture Pic, 0, 0, w, h, 0, 0, Pic.Width, Pic.Height

// return result
Return NewPic
End Function


Sincerely
Christian