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

ID="cpRubrik"
runat="server"
ImageUrl="~/img/colorpicker.png"
/> ;

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


Similar Messages:

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:

[Code]....

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:

[Code]....

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

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

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

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

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

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
};
border.ApplyTemplate();
RenderTargetBitmap renderTargetBitmap =
new RenderTargetBitmap(width, height, 90, 90, PixelFormats.Pbgra32);
renderTargetBitmap.Render(border);
BitmapEncoder bitmapEncoder =
new PngBitmapEncoder();
bitmapEncoder.Frames.Add(BitmapFrame.Create(renderTargetBitmap));
bitmapEncoder.Save(memoryStream);
});
t.SetApartmentState(ApartmentState.STA);
t.Start();
bool success = t.Join(5000);
if (success)
return memoryStream.ToArray();
else
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

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

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

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.

[Code]....

View 8 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:

[URL]

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

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;
origBMP.Dispose();
newBMP.Save(Server.MapPath("ImageUpload\" + r + ".Jpeg"), System.Drawing.Imaging.ImageFormat.Jpeg); //exception throw "A generic error occurred in GDI+."
newBMP.Dispose();
objGra.Dispose();

View 3 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?

[Code]....

View 1 Replies

Web Forms :: Use System.Drawing.Bitmap Class Into Other Class?

Oct 5, 2010

How can I to use System.Drawing.Bitmap class into athoer class?

using System.Data;
using System.Collections;
using System.Globalization;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace University
{
public class Class1
{
System.Drawing.Bitmap BMP=new System.Drawing .Bitmap();
}
}

when I use System.Drawing.Bitmap gives error this class does not exists

View 2 Replies

WebMatrix :: Get An Error Message "filetype Blocked".The File Is Called Test.jpg And Is Drawn To The Screen As A Bitmap?

Oct 25, 2010

I am working on a website that draws fractals on the screen. It was my intention that with a right mouse click the picture could be saved to the visitor's computer. But that I get an error message "filetype blocked".The file is called test.jpg and is drawn to the screen as a bitmap. Could anybody tell me how to 'unblock' the right mouse click so that a visitor can save a picture he or she likes?Maybe it would be possible to let people download the image? But how would that work?

View 3 Replies

Web Forms :: Converting Aspx To PDF?

Oct 3, 2010

[code]....

the above code only converts controls in dvtext (div) like label name and textboxname to pdf. after entering values into textboxes. it is not convert them to pdf. it only converts control names.

View 3 Replies

Web Forms :: Converting C# To Vb.net Error?

Jun 3, 2010

I worte a code with for loop in c# and how I want to run it in an VB.net application but it gives me an error.

This is my working C# code :

foreach (var email in users)
{
email_address = email.email;
}

This is my code where I am getting an Error.

For Each email As var In users
email_address = email.email
Next

The Error is type Var is not Defined.

View 16 Replies

Web Forms :: Converting HTML To Pdf Using ItextSharp?

Aug 27, 2010

I want to convert my current asp.net page which will be running, to PDF when i click a button present on the page. I have buttons textboxes and text on the page. itextsharp.dll is not showing textboxs and buttons on the page its only showing plain html text.. what should i do?

View 3 Replies

Web Forms :: Converting A SharePoint List To .NET

Oct 1, 2010

I need to convert a SharePoint List to ASP.NET, including its column filters etc.

Aside from the underlying data which will be housed in a SQL Server table, what are good control choices on ASP.NET side for this? (I'm not sure if ASP.NET Gridview will have all the necessary features.)

View 3 Replies

Web Forms :: Getting An Error Converting This IP To String?

Jun 16, 2010

im getting an error converting this IP to string

[Code]....

{

View 3 Replies

Forms Data Controls :: Converting Id Key Into Name?

Feb 13, 2011

I'm using related tables. The table being displayed in gridview uses the ID from a different table. How to I have the ID show up as a different column (ex. Name) at run-time?

View 3 Replies







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