MemoryStream objStrmSelected =
new MemoryStream();
System.Drawing.
Image objImageSelected = System.Drawing.Image.FromFile("ur jpg/gif image path);//pathImage1
is the physical path of that image
objImageSelected.Save(objStrmSelected, System.Drawing.Imaging.ImageFormat.Jpeg);
MemoryStream objStrmBckgrnd =
new MemoryStream();
System.Drawing.
Image objImgBckgrnd = System.Drawing.Image.FromFile("second image path");
//pathImage2 is the physical path of this image
System.Drawing.Graphics objGrBckgrnd = System.Drawing.Graphics.FromImage(objImgBckgrnd);
InterpolationMode.HighQualityBicubic;
int width1 = objImgBckgrnd.Width;
//--width of the background image
int height1 = objImgBckgrnd.Height;//--height of the background image
int width2 = objImageSelected.Width;
//--width of the second image
int height2 = objImageSelected.Height;//--height of the second image
//--now x off set will be the result of the subtraction of the bigger(background) image and the smaller image width
int x = width1 / 2 - 100 / 2;
int y = height1 / 2 - 100 / 2;
//--draw that selected image on the background image on that position
objGrBckgrnd.DrawImage(objImageSelected, x, y, 100, 100);
objGrBckgrnd.Save();
//objImgBckgrnd.Save(objStrmBckgrnd, System.Drawing.Imaging.ImageFormat.Jpeg);
objImgBckgrnd.Save("path whr u want to save the image file", System.Drawing.Imaging.ImageFormat.Jpeg);
Member
58 Points
66 Posts
merge 2 image with transparent ???
Aug 21, 2008 11:59 PM|5ugeng|LINK
Hello everybody,
i want to get your help, i have the problem like this
i have draw one image like background image
and then i want to draw image again like photo...
and i want the photo is transparent with the background...?
i try and try but not successfull.. Maybe you can help me solve my problem
Thank you very much
merge 2 image with transparent ???
Participant
814 Points
337 Posts
Re: merge 2 image with transparent ???
Aug 22, 2008 06:23 PM|yassir.2|LINK
can u explain more ?
Member
58 Points
66 Posts
Re: merge 2 image with transparent ???
Aug 23, 2008 03:19 AM|5ugeng|LINK
okay, not problem
sorry if my explanation is not clear
my problem is i want to merge 2 images and one image is transparent to other images...
Example the photo is transparent to the background...
but the extension of my file is .jpg
can i do that? or maybe any solution like change the extension like .gif maybe?
i don't know how to solve this problem..
Thank you very much
Re: merge 2 image with transparent ???
Member
10 Points
2 Posts
Re: merge 2 image with transparent ???
Aug 28, 2008 02:03 AM|sathya881982|LINK
using
System;using
System.Data;using
System.Configuration;using
System.Collections;using
System.Web;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls;using
System.Drawing;using
System.Drawing.Drawing2D;using
System.Drawing.Imaging;using
System.Net;using
System.IO;public
partial class OverlappImages : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
overlapimage();
}
protected void overlapimage(){
MemoryStream objStrmSelected = new MemoryStream();System.Drawing.
Image objImageSelected = System.Drawing.Image.FromFile("ur jpg/gif image path);//pathImage1 is the physical path of that image objImageSelected.Save(objStrmSelected, System.Drawing.Imaging.ImageFormat.Jpeg); MemoryStream objStrmBckgrnd = new MemoryStream();System.Drawing.
Image objImgBckgrnd = System.Drawing.Image.FromFile("second image path"); //pathImage2 is the physical path of this image System.Drawing.Graphics objGrBckgrnd = System.Drawing.Graphics.FromImage(objImgBckgrnd);objGrBckgrnd.CompositingQuality =
CompositingQuality.HighQuality; objGrBckgrnd.SmoothingMode = SmoothingMode.HighQuality;objGrBckgrnd.InterpolationMode =
InterpolationMode.HighQualityBicubic; int width1 = objImgBckgrnd.Width; //--width of the background image int height1 = objImgBckgrnd.Height;//--height of the background image int width2 = objImageSelected.Width; //--width of the second image int height2 = objImageSelected.Height;//--height of the second image //--now x off set will be the result of the subtraction of the bigger(background) image and the smaller image width int x = width1 / 2 - 100 / 2; int y = height1 / 2 - 100 / 2; //--draw that selected image on the background image on that positionobjGrBckgrnd.DrawImage(objImageSelected, x, y, 100, 100);
objGrBckgrnd.Save();
//objImgBckgrnd.Save(objStrmBckgrnd, System.Drawing.Imaging.ImageFormat.Jpeg); objImgBckgrnd.Save("path whr u want to save the image file", System.Drawing.Imaging.ImageFormat.Jpeg);objStrmSelected.Dispose();
objImgBckgrnd.Dispose();
}
}
by
sathya
India
sathya