I am genereating a Bitmap image on fly. I don't want to store it on the server filesystem, instead I need to directly save that into database. Another page will retrieve this image later on.
I am using below mentioned code but its not working as expected, please guide me
SQL only supports so many bytes before the data needs separating. I've never found a good workaround to this and always revert to storing the data to disk and saving a reference to it.
If it helps, mark as answer - your approval helps with my recovery ;)
ajaysharmaap...
Member
209 Points
52 Posts
Save Dynamically generated Bitmap into database and retrieve it
Jan 14, 2013 11:32 AM|LINK
Hi,
I am genereating a Bitmap image on fly. I don't want to store it on the server filesystem, instead I need to directly save that into database. Another page will retrieve this image later on.
I am using below mentioned code but its not working as expected, please guide me
Bitmap outputImage = new Bitmap(outputImageWidth, outputImageHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb); using (Graphics graphics = Graphics.FromImage(outputImage)) { System.Drawing.Image imgNew = System.Drawing.Image.FromFile(MapPath("BaseImage.jpg"); graphics.DrawImage(imgNew, 10, 50, new Rectangle(new Point(), imgNew.Size), GraphicsUnit.Pixel); } } strCartName = DateTime.Now.ToString().Replace("/", "").Replace(" ", "_").Replace(":", "") + ".jpg"; byte[] imageBytes = (byte[])TypeDescriptor.GetConverter(outputImage).ConvertTo(outputImage, typeof(byte[])); hdnByteArray.Value = imageBytes.ToString();Thanks for your time....
Regards
Ajay Sharma
-------------------------------------------
kidshaw
Participant
1178 Points
252 Posts
Re: Save Dynamically generated Bitmap into database and retrieve it
Feb 05, 2013 09:12 PM|LINK