Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bitarray Email

Status
Not open for further replies.

LiquidPixel

Programmer
Dec 12, 2006
11
US
I have bitmapData (bitArray) coming out of Flash and being parsed into a Bitmap object in ASP.NET. I can get the image to render on the screen via:

Bitmap.Save(Response.OutputStream, ImageFormat.Jpeg);

Obviously this writes during the response call BUT what I need to do is have this image not render on screen but email to a user as either an attachment or inline image. I simply don't know how to package and/or render the image to an email.

Subsequently I would have the page Response.Redirect to a "your info has been sent page".

Does someone know how to render and/or inject the image and send it via email???

Any help here would be greatly appreciated.

Thanks
 
You would need to save that Stream to a file. So instead of Bitmap.Save(Stream) do Bitmap.Save("file.bmp");

Create an email with attachment, send.

Then delete the image (unless you need to keep it after ti's sent)

HTH
 
Well I have tried this BUT the file doesn't appear in a physical location. Do I need to use a File.IO arrangement???
Should I see a physical file named file.bmp. I also have tried a generic name like image.jpg. It also does not exist.

I do get the theory on how this is done but I am not a server-side programmer so I really need specifics on how to do this. I am also not hugely familiar with the .Net libraries.

ASP is definitely receiving the data and I know how to send an email using ASP. So I am really looking for a thorough explanation on how to take the bitmap (created by the bitArray) and access that object for the email.

Obviously the Bitmap object exists in my program because I can access it in the Response functionality. Is there a way I can take that object without saving it to stream or file and embed it to render visually within an email message.

Here is the Page_Load method for this

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

protected void Page_Load(object sender, EventArgs e)
{
// Retrieve the pixel data from Flash
string pixelData = Request["pixels"];

int width = int.Parse(Request["width"]);
int height = int.Parse(Request["height"]);

Bitmap bmp = null;

string curPixelColor = String.Empty;

int x = 0;
int y = 0;

if (pixelData != String.Empty)
{
bmp = new Bitmap(width, height);

for (int i = 0; i < pixelData.Length / 6; i++)
{
curPixelColor = pixelData.Substring(i * 6, 6);
bmp.SetPixel(x,y, ColorTranslator.FromHtml("0x" + curPixelColor));

if(x==width-1)
{
x = 0;
y++;
}
else
{
x++;
}
}
}


Response.ContentType("image/jpg");
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
bmp.Dispose();
Response.End();

}
 
You will have to specify the filename and path for where it needs saving. See the help files for example:



-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
I figured this out last night using MapPath() thanks for your help guys.


P
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top