Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 2nd, 2004, 12:28 PM
Registered User
 
Join Date: Mar 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default BinaryWrite an image

I am trying to BinaryWrite an image from a binary string that I am storing in the web.config file. The image is just a 1x1 pixel gif. I am setting the content type to "image/gif", but the output is just my string. Any suggestions? Code is below:

byte[] bytes = Encoding.UTF8.GetBytes(ConfigurationSettings.AppSe ttings["PixelBinaryData"].ToString());
httpContext.Response.ContentType = "image/gif";
httpContext.Response.BinaryWrite(bytes);



Reply With Quote
  #2 (permalink)  
Old March 2nd, 2004, 03:58 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You might want to look into embedded resources for this. I have had good luck with using those for this very purpose. There is a utility you can download that will create a resource file for the image you tell it to convert, then you can just copy the one XML node for that image into an existing resource file. The image resource will get compiled right into the assemble/executable.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #3 (permalink)  
Old March 3rd, 2004, 01:14 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik Send a message via Skype™ to melvik
Default

its a sample to save image file in a Database,I hope u need this.
Code:
                if( FileOpenDlg.ShowDialog() == DialogResult.OK)
                {
                    string file = FileOpenDlg.FileName;
                    System.IO.FileStream stream = new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    byte[] buffer = new byte[stream.Length];
                    stream.Read(buffer, 0, (int)stream.Length);
                    stream.Close();
                    string strName = System.IO.Path.GetFileNameWithoutExtension(file);

                    //SavePic
                    DataRow PicRow;
                    PicRow = dsDabir1.Tables["Images"].NewRow();
                    PicRow.SetParentRow(IncomeRow);
                    PicRow["IsScaned"] = 0;
                    PicRow["ImgPic"] = buffer;
                    dsDabir1.Tables["Images"].Rows.Add(PicRow);
                    buffer = null;
                }//if


Always:),
Hovik Melkomian.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload image-create & save thumbnail-display image angshujit ASP.NET 2.0 Professional 6 July 11th, 2013 10:34 PM
Copy kodak image edit control's image to clipboard vishwanathduddilla Visual Studio 2005 0 November 3rd, 2008 09:10 AM
set image on <asp:Image> stored in DataBase myself.panku ASP.NET 2.0 Professional 1 August 11th, 2008 10:41 AM
Response.BinaryWrite issue alliancejhall ASP.NET 2.0 Basics 1 November 14th, 2007 10:29 PM
Response.BinaryWrite hcweb Classic ASP Basics 0 June 20th, 2007 01:56 PM



All times are GMT -4. The time now is 04:42 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.