[Gtk-sharp-list] Image resize on image widget control

Andrew York andy at brdstudio.net
Tue Dec 15 11:59:56 EST 2009


Use the Gdk.Pixbuf to resize the images like this:

img.Pixbuf.ScaleSimple(50,150, Gdk.InterpType.Nearest);
or when you declare the new Pixbuf you can resize it.

I have found this method the easiest way to get Pixbuf from a resource, this assumes the resource is the current assemble of course.
Gdk.Pixbuf.LoadFromResource("resourceImageId");


I hope this helps.

SpoodyGoon



On 12/15/2009 3:37 AM, dkarantonis wrote:
> Hi,
> i would like to ask how i could resize an image from the project resources
> inside an image widget control.
>
> What i am doing for the moment is loading the image and try to resize it by
> assigning hard coded width and height values, but the image does not render
> with the specified width and height but with its original values.
>
> //create image from resource
> Image img = new Image (myAssembly, "resourceImageId");
>
> //resize image
> img.WidthRequest = 50;
> img.HeightRequest = 150;
>
> //assign image to image widget
> imgControl.PixBuf = img.PixBuf();
>
> Any ideas?
>
> thanks in advance
>    






More information about the Gtk-sharp-list mailing list