Using GdPictures in MVC .net C#

Example requests & Code samples for GdPicture Toolkits.
Post Reply
atiqi36
Posts: 1
Joined: Sun Mar 16, 2014 1:23 pm

Using GdPictures in MVC .net C#

Post by atiqi36 » Sun Mar 16, 2014 2:01 pm

Hi,

I am stuck with this problem. We need to create high resolution and quality images as the website is related to printing so when customer images are printed they have to be downloaded in big resolution according to the size. The biggest size we do is 130 cm one side so if the image is high quality we regularly get Out of Memory exception while creating the image. I have been using .Net bitmap, Graphics code for this but still not getting better for high resolution images so I tried to use third party controls hence trying GdPictures. Here is the code I have written just to check if it can handle.

var newBitMapGD = new GdPictureImaging();
int imgId = newBitMapGD.CreateGdPictureImageFromBitmap(b);
var status = newBitMapGD.Resize(imgId, 21000, 6000, System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic);
Bitmap returnBmp = newBitMapGD.GetBitmapFromGdPictureImage(imgId);
var delStatus = newBitMapGD.ReleaseGdPictureImage(imgId);
return returnBmp;

As you can see the Resize has 21000 width and 6000 height. This is giving Out of Memory exception which we get in normal .Net code as well as it doesn't handle Width/Height more than 10k normally and fall over. We have a dedicated server with 125GB Ram so I don't know why IIS won't use that. Can someone please help?

Here is the normal .Net function which we use;

public virtual Bitmap ResizeImage(Bitmap b, int targetSizeWidth = 0, int targetSizeHeight = 0, string fileExtension = "jpg")
{
var newSize = CalculateDimensions(b.Size, targetSizeWidth, targetSizeHeight);

if (newSize.Width < 1)
newSize.Width = 1;
if (newSize.Height < 1)
newSize.Height = 1;

var newBitMap = new Bitmap(newSize.Width, newSize.Height); Falls over here with 20000 width
var g = Graphics.FromImage(newBitMap);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.DrawImage(b, 0, 0, newSize.Width, newSize.Height);
b.Dispose();
var ep = new EncoderParameters();
ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, this.ImageQuality);
ImageCodecInfo ici = GetImageCodecInfoFromExtension(fileExtension);
if (ici == null)
ici = GetImageCodecInfoFromMimeType("image/jpeg");
return newBitMap;

}

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: Using GdPictures in MVC .net C#

Post by SamiKharma » Wed Apr 23, 2014 3:13 pm

Hi,

Are you sure you are running your application under X64? I tried resizing an image to 21000 * 6000 and I could easily achieve that with GdPicture.

Best,
Sami

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest