C# - Embedding A Bitmap In WebResource

Apr 6, 2010

I am generating a System.Drawing.Bitmap on the fly in an ASP.NET Custom Web Server Control, and then I want to serve this bitmap as part of the WebResource, because I do not want to save it on the hosting computer. Is there a way to instruct ASP.NET to serve the generated System.Drawing.Bitmap as part of it's WebResource? (therefore making it an "Embedded Resource")

View 1 Replies

Similar Messages:

Web Forms :: Converting Bitmap To Ehm.bitmap

May 5, 2010

I have a colorpicker.png file and track the pixel clicked in codebehind using GetPixel. Works like a charm, but I read that converting to a bitmap on the fly is rather heavy on the server. Therefore I saved my .png file as a .bmp as well, so that a converted file would already exist. However, I don't seem tobe able to just use the bitmap file, but need to create a new bitmap from the bitmap...

My question is: The code below works (I provide it here for those who might need it - simply add the code below to codebehind and this code in your aspx page <asp:ImageButton

/> ;

also note that the image can be whatever you want - a photo or a screendump of a colorpicker from say Photoshop or VS; and note that it's wise to put everything you need in an updatepanel). Should I write something else in order to get smarter access to the bitmap?

Protected Sub cpRubrik_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles cpRubrik.Click
tbUtseenderub.ForeColor = BytFarg(e.X, e.Y)
End Sub
Protected Function BytFarg(ByVal x As Integer, ByVal y As Integer) As Color
Dim myBitmap As New Bitmap(Server.MapPath("~/img/colorpicker.bmp"))
Dim clr As Color = myBitmap.GetPixel(x, y)
Return clr
End Function

View 1 Replies

C# - Add Bitmap To HTML?

Jun 23, 2010

I have an ASP.NET web form. This web form has an event handler that generates some HTML. This HTML is based on the time-of-day, that is why it is created in the event handler. Based on the time of day, an image is created programmatically via the following method:

private Bitmap GetImageForTime(DateTime time)
Bitmap bitmap = new Bitmap();
// Dynamically build the bitmap...
return bitmap;

want to call this method when the HTML is being generated. However, I do NOT want to write the image on the server. Instead, I would like to figure out a way to write it out along with the HTML. In a sense, I'm trying to accomplish the following:

protected void myLiteral_Load(object sender, EventArgs e)
string html = "<table><tr><td>";
html += GetImageForTime(DateTime.Now); // This is the problem because it's binary.
html += "</td><td>";
html += GetWeatherHtmlText();
html += "</td></tr></table>";
myLiteral.Text = html;

View 6 Replies

How To Assign Bitmap To Imagecontrol

Jan 7, 2010

i am trying to bind image to image control . but image is bitmap data. how can i?

View 1 Replies

Generating Bitmap Of WPF UIElement

Aug 1, 2010

I'm trying to generate a bitmap off a WPF border. The whole thing sits in a asp.net app (server side of course) running .net 4.0. The problem is, that the generated image is, well, empty. Does anyone have an idea why? Here's the code.

public static byte[] Draw(int width, int height)
MemoryStream memoryStream
= new MemoryStream();
Thread t = new Thread(delegate()
System.Windows.Controls.Border border = new System.Windows.Controls.Border()
Background = Brushes.Red,
BorderBrush = Brushes.Green,
CornerRadius = new System.Windows.CornerRadius(5),
Width = width,
Height = height
RenderTargetBitmap renderTargetBitmap =
new RenderTargetBitmap(width, height, 90, 90, PixelFormats.Pbgra32);
BitmapEncoder bitmapEncoder =
new PngBitmapEncoder();
bool success = t.Join(5000);
if (success)
return memoryStream.ToArray();
throw new Exception("Fail");

The result is quite bad, as I said the thing returns the image with the right width and height, but it's empty, so I guess I don't mess the thing up with the threading bit.

View 1 Replies

Convert Image From URL To Bitmap

May 19, 2012

I am trying to convert a image (from url) to bitmap here the code i was using but its for using a image from your computer (file) Dim bmp As bitmap = bitmap.FromFile(TextBox1.Text) I entering a url instead of a file location but i get a URI error

View 2 Replies

Web Forms :: Display The Bitmap Image

Feb 10, 2011

i had drawed a graph by clicking a analyze button, however when i click it, it will go to a new screen. below is my coding:


below is the condition i want, when i click the button Analyze, the image (graph) is showed under the button with the header and template:


my current condition is when i click the button analyze, it will totaly display the graph only without the header and template as print screen below: how to change the coding to let the template and heaser showed together with the bar chart?

View 1 Replies

C# - Save A Bitmap As A 16 - Color Grayscale GIF Or PNG?

Jan 4, 2010

In ASP.NET C# I'm trying to save a bitmap image as an 16-color non-transparent grayscale image as either a PNG or GIF. I assume I have to create a palette and then somehow attach the palette to the image but not sure how to go about doing this. The source image is a 24-bit color Bitmap.

View 2 Replies

C# - Create Curved Text On A Bitmap?

May 10, 2010

I am currently dynamically creating a bitmap and using the graphics object from the string from the bitmap to Draw a string on it like so.

System.Drawing.Graphics graph = System.Drawing.Graphics.FromImage(bmp);
graph.DrawString(text, font, brush, new System.Drawing.Point(0, 0));

This returns a rectangle shaped bitmap with the string written straight across from left to right. I would like to also be able to draw the string in the shape of a rainbow. How can I do this?

View 2 Replies

How To Write A Code About Get A Picture From Url And Save As Bitmap

Mar 17, 2010

I had write a code about get a picture from url and save as bitmap. However, there was a problem in HttpWebResponse. It didn't run the code start from HttpWebResponse.Then my whole website die there.


View 8 Replies

Web Forms :: Save Webpage As Bitmap Or Image?

Sep 20, 2010

I have to save the webpage as image in my system folder. I am saving them using stream.....but the page is not displayed as Image....It opened only through browsers.

View 2 Replies

C# - Parameter Is Not Valid Calling Bitmap.Save()?

Mar 22, 2011

This in in an ASP.NET application.

Locally, this code runs fine, but on our production server, it throws an exception of 'Parameter is not valid' when Bitmap.Save() is called.

Should I not be using System.Drawing.Bitmap because its not recommened based on this:


Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.

What else could I use?

Bitmap myBitmap = new Bitmap(img);
myBitmap.SetResolution(img.HorizontalResolution, img.VerticalResolution);
// get the tiff codec info
ImageCodecInfo myImageCodecInfo = GetEncoderInfo("image/tiff");
// Create an Encoder object based on the GUID for the Compression parameter category
System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Compression;
// create encode parameters
EncoderParameters myEncoderParameters = new EncoderParameters(1);
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, (long)EncoderValue.CompressionCCITT4);
myEncoderParameters.Param[0] = myEncoderParameter;
// save as a tiff
myBitmap.Save(input, myImageCodecInfo, myEncoderParameters);

View 3 Replies

Web Forms :: Writing Bitmap File On Server?

Oct 19, 2010

I'm making an application which takes image from user upload it to server and then perform any image processing like to convert to gray or invert etc.

My problem is this when i did the process on image to gray it or invert then how to write this new file on server or is there any other way so that i would be able to show this (new) image to user and make it downloadable?

View 2 Replies

Internet Explorer - Convert VML Graphic To Bitmap On The Server

Dec 14, 2010

I'm using RaphaelJS. The browser renders a chart for me (which is in VML as all my users are on IE). I want the user to be able to save this image and share it normally eg paste into an email, into powerpoint, into a document etc etc.

Problem is not many things can render VML. I can easily get the VML markup describing the image back to the server. All I want to do is convert it to some kind of more universal format eg PNG, BMP, GIFF, whatever which I can then allow the user to download. I've seen lots of people struggling with this. I would have thought the seeing as VML is Microsoft's proprietary SVG format they might have at least provided facilities within their own languages (C#,VB.net) to convert VML to bitmaps. (Incidentally I can't use PHP - I've seen a lot of people attempting to solve this with a PHP based solution)

View 1 Replies

Configuration :: Bitmap Image Saving When Running The Application On Iis Server

Apr 2, 2011

I m facing one problem which is related to Bitmap Image Actually My image is saved properly without iis server but when i run application on iis server then its give Exception "A generic error occurred in GDI+."
I m using this code-

Byte[] bytes = (Byte[])ds.Tables[0].Rows[r][1];
MemoryStream memStream = new MemoryStream();
memStream.Write(bytes, 0, bytes.Length);
System.Drawing.Bitmap origBMP = new System.Drawing.Bitmap(memStream);
System.Drawing.Bitmap newBMP = new System.Drawing.Bitmap(origBMP, 100, 150);
System.Drawing.Graphics objGra = System.Drawing.Graphics.FromImage(newBMP);
objGra.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
objGra.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
newBMP.Save(Server.MapPath("ImageUpload\" + r + ".Jpeg"), System.Drawing.Imaging.ImageFormat.Jpeg); //exception throw "A generic error occurred in GDI+."

View 3 Replies

Web Forms :: Display System.Drawing.Bitmap Object On Page?

May 14, 2010

I am trying to built a WebForm with module where the user can see himself in his webcam. I am using AForge.NET framework to control the webcam.

AForge returns every frame as Bitmap object (System.Drawing.Bitmap) and now i have to display it in my WebForm. In the Windows form I would achieve it by assigning Bitmap to the PictureBox control but how do i do it in WebForm? There is only Image control avilable (System.Web.UI.WebControls.Image) which doesn`t have any .Source propery apart form .Url. How do I display Bitmap object on the page ?

View 2 Replies

C# - Changing The WebResource.axd URL?

Feb 26, 2010

ASP.NET automatically includes the following script tag:

<script src="/WebResource.axd?d=8H_C0aee9xE8e9a-3YoRhA2&t=633413907763620168" type="text/javascript"></script>

However the clients site is being proxied through another site. So the URL to the root of their site is:


So I need to prefix the WebResource.axd with /somename so the resulting tag will look like this:

<script src="/somename/WebResource.axd?d=8H_C0aee9xE8e9a-3YoRhA2&t=633413907763620168" type="text/javascript"></script>

What I am not sure is how to actually set this? Is there a web.config setting I can set so it has this prefix?

View 2 Replies

C# - How To Adjust Size Of Programatically Created Bitmap To Match Text Drawn On It

May 7, 2010

I have the following .ashx page that takes some query string parameters and returns a bitmap with the specified text written on it. The problem I have is that I am currently just manually setting the initial size of the bitmap at 100 X 100 when what I really want is to have the bitmap be just big enough to include all the text that was written to it. How can I do this?


View 1 Replies

Can Combine WebResource.axd CSS Requests

Sep 15, 2010

I have developed some ASP.NET server controls which include their own javascript and css files. A lot of these controls use jQuery extensions which, as you know, often include their own css files.

I'm using Telerik's RadScript manager which combines the javascript like a boss. However, I'm using the AjaxToolkit's ClientCssResource attribute to include the css files in my server controls, and I have noticed that the CSS files are not getting combined at all. My pages have 10-15 WebResource.axd requests for css files for my server controls.

Everything I find only is about combining javascript, and nothing tells me how I can combine the CSS files. Does anyone know if there is a way to combine the CSS dynamically (I don't want to manually combine as each page might use a different subset of the server controls)?

View 2 Replies

C# - Change The Requested Url Of WebResource.axd?

Apr 4, 2011

My web application [URL] is currently requesting the WebResource.axd file like this:

<script src="/WebResource.axd?d=xxx" type="text/javascript"></script>

As we're using urlrewiting in a Netscaler to forward all requests for the "/social" folder onto a seperate server farm containing this app, the "/" root path won't resolve correctly as it will be requesting the resource from the something.com app.

Therefore I need to change the url of the requested script to either request it explicitly:

<script src="/social/WebResource.axd?d=xxx" type="text/javascript"></script>

or to request it using a relative path:

<script src="WebResource.axd?d=xxx" type="text/javascript"></script>

So far I've looked at overriding the render method, using a control adapter and various other things but haven't really got anywhere as of yet.

View 1 Replies

AJAX :: Scriptresource.axd And Webresource.axd?

Mar 21, 2010

My website is looking in the wrong place for the scriptresource.axd and webresource.axd. How do I point it at the correct subfolder? Or how do I set it so that scriptresource.axd and webresource.axd are stored in the root of the website?All the ajax is done within subfolders. The web.config is at the root of the website.

View 2 Replies

C# - WebResource.axd Throwing Exceptions In Web Farm?

Jan 17, 2011

We have an array of about 12 servers serving a website. Over the past few hours, one single server has started throwing exceptions for WebResource.axd and ScriptResource.axd requests.


System.Web.HttpException - This is an invalid script resource request.

Stack Trace

at System.Web.Handlers.ScriptResourceHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Broken server URL


All other servers URL


I have checked the web.config, machine.config for every server and they're all identical. The only difference been able to find so far is that prior to the problem commencing, the servers were patched, after which, the problematic server looks to be using different version of the System.Web.dll to the others?

View 2 Replies

Web Forms :: Is It Possible To Change The Referral To The WebResource.axd

Dec 9, 2010

Is it possible to change the referral to the WebResource.axd from:

<script src="/WebResource.axd
<script src="http://mysite/WebResource.axd

View 3 Replies

Webresource.axd Attempt To 'download' When I Reference It In This URL?

Mar 5, 2011

I have someone doing a penetration test on a site and they are trying to exploit WebResource.axd. I'm confused because whenever I try his URL I either get it trying to download to a text file in IE or displaying as text on FF


He says that it is giving him an alert with 16146 in it, I can't fix it because I can't even duplicate it.

I have customErrors defined within web.config, everything is going to the same concise error page. I kind of get how you COULD exploit this file but I just want to know what I managed to do that causes it to come across text.

View 1 Replies

Embedding Whole Directory Structure?

Dec 13, 2010

I have a large directory structure with JavaScript, images, etc. that depend on each other. I would like to encapsulate it all into a DLL so I only have to reference one thing and not have multiple copies of all these files across projects.

Because the files depend on each other, I'm thinking I can create an IHttpModule that registers a route to accept URLs such as /MyEmbeddedDir/subdir/file.js. Anything in MyEmbeddedDir would then be handled by a custom IHttpHandler that does the correct mapping. Each web application would then need to reference the DLL and add the module and handler to web.config. Does this seem reasonable?Also, is there an easier way to embed/reference the files than to set the build action to embedded resource and add [assembly: WebResource(...)] to each file (there are dozens!)?Edit: If I'm not using WebResource.axd then I shouldn't need to add [assembly: WebResource(...)]

View 2 Replies

Copyrights 2005-15 www.BigResource.com, All rights reserved