.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Mouse Drawing in Bitmap and repositioning bitmap

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :Windows Application
Dear Friends,                  I have made an application similar to this: http://www.bobpowell.net/simpledraw.aspx. But I have made few changes like I have used only the mouse draw option where the drawing is zoomed to specific level with Matrix transformation and I have snapped the mouse to the current mouse coordinates. The programe is working fine. Problem arises when I try to place the same bitmap in X and Y axis many time. After placing bitmap in both the axis once again repositioned the mouse like whenever the mouse is clicked on repositioned bitmaps it draws into the original bitmap and displays the image in all positioned bitmaps. I have solved the mouse back tracking issues.                   The major problem I face here is that when the mouse crosses one bitmap to another bitmap it ticks a continuous line. That is whenever mouse crosses 0th pixel to the last pixel of previous positioned bitmap or from last pixel to 0th pixel of next positoned bitmap. Whereas I need smooth mouse drawing programme with bitmaps positioned many time so that the drawn image should look continuous. I couldnt give code because it is huge.               &n

View Complete Post

More Related Resource Links

Displaying a System.Drawing.Bitmap in a WPF Image control

How would I convert a System.Drawing.Btimap into a comparable WPF image control so I can display in on my WPF window? Thanks

Bitmap drawing

I am trying to draw objects (line, etc) on a Bitmap. However, I have run into some problems: the origin of the bitmap coordinate system is at the top-left corner of the bitmap. How can I have it set to the bottom-left corner? Also, I need to draw some real world objects on this bitmap: how can I transform or map the real world coordinates on the bitmap coordinate space? Any help is really appreciated as I am totally lost on this one.

Unable to cast COM oject of type 'System.__ComObject' to class type of 'System.Drawing.Bitmap' .

 private void DirectXViewer_DragDrop(object sender, DragEventArgs e)


   mousePressedFlag = false;



    Object obj = e.Data.GetData(typeof(Bitmap));





      Bitmap image = (Bitmap)((Bitmap)obj).Clone();

      RenderImage = image;



     catch(Exception ex)








private void DirectXViewer_MouseMove(object sender, MouseEventArgs e)


   if (mousePressedFlag)


    if(cacheBitmap != null)

     this.DoDragDrop(new Bitmap(cacheBitmap), DragDropEffects.Copy);




Hi All,

I try to d

NotSupportedException System.Drawing.Bitmap


I have a VB.Net program which is running on CF MobilePC 2003.  In the form creation logic (generated by VS), the creation of a bitmap on the form (in a PictureBox) gets the following exception:

Me.pbStop.Image = CType(resources.GetObject("pbStop.Image"), System.Drawing.Image)


System.NotSupportedException was unhandled



    at System.Resources.ResourceReader.LoadObjectV2()

System.Drawing.Bitmap.SetResolution is completely broken on Windows 7


Bitmap.SetResolution does nothing on Windows 7. It works fine on XP and Vista. This code demonstrates the problem:


            foreach (string file in Directory.GetFiles(@"C:\Temp\input"))


                string newFile = "";

                using (var bitmap = (Bitmap)Image.FromFile(file))


                    bitmap.SetResolution(200, 200);

                    newFile = Path.Combine(@"C:\Temp\output", Path.GetFileName(file));

                    bitmap.Save(newFile, ImageFormat.Png);


                using (Image image = Image.FromFile(newFile))



Bitmap FromFile space "file not found"


I am using aspose.slides to create PPTx's. Some of the process involves loading jpg's from another server and including them in the presentation. This works fine in my development environment. When I upload the site to its server, the jpg loading fails.

I am trying to access jpg's on the other server by:

   oFS = New FileStream(sFile, FileMode.Open, FileAccess.Read)

This causes an access violation error when run from the server.

I also boiled the code down to reading the file directly:

   oImg = System.Drawing.Bitmap.FromFile(sFilePath)

This causes a file not found error.

We have narrowed the problem down to the fact that the File Path has a space in it. How does one solve this problem (while still keeping the space, there is a lot of legacy data)? I have tried replacing the space with %20 or +. I have tried using Server.UrlEncode. The error message always comes back with the encoding in place (like no decoding

Bitmap to Image Control - ImageUrl


 This is my first attempt at using the drawing features of asp.net.  I just want to start simple, and create a single color bar based on a value for a single graph.  I wrote this so far, but I can't figure out how to take the bitmap I just created, and apply it to the Image Control. Do I have to save the file first, and then reload it.

Plus, my box keeps coming out pure black, I trying to fill the box with a color. 

This is part of a web custom control, in which I dynamically created an Image Control. I want to apply the bitmap I made to the image control. 


Dim imgGoogle As Image
imgGoogle = New Image
imgGoogle.ImageAlign = ImageAlign.AbsMiddle
imgGoogle.ImageUrl = cs.GetWebResourceUrl(rsType, "ice5software.BotCatcher.Google.gif")
Private Sub DrawBarGraph_Google(ByVal BarValue As Integer)

	Dim objBitmap As System.Drawing.Bitmap
	Dim objGraphics As S

encoding/decoding a string to/from bitmap


I have two methods:

Encode - takes a string, converts it to array of bytes, uses bytes to specify colors, creates a color and sets a pixel based on bytes

Decode - takes a pixel, retrieves color (R,G,B) bytes and converts them to characters, that produces a string which was previously encoded

I'm using two for loops (img height/width) to specify position and access pixels

The issue is that once display (Control Panel\Appearance and Personalization\Display) changes to anything other then "Smaller - 100%",
bytes have different values during decoding, thus different string is produced (corrupted).

If the setting is set to "Smaller - 100%" the results are normal.

What can I do to avoid that problem?

Thanks in advance

Writing Bitmap to Response.OutputStream - Generic Error Occured in GDI+



This is what I'm trying to do when I get the error on the server (it works on my local machine):

System.Drawing.Image image = System.Drawing.Image.FromFile(filepath);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(image); 

Response.ContentType = "image/bmp";
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Bmp);

I don't think it can be a permissions problem because this works on the server:

System.Drawing.Image image = System.Drawing.Image.FromFile(filepath);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(image);

Response.ContentType = "image/jpeg";
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

So how do I get this to work for a bitmap?


how to create a Bitmap with size(20000,30000) in c#

hi how to create a BitMap with size (20000,30000) using C#

Change Bitmap Resolution and Turn Black & White

i use this method to resize bitmaps. Bitmap OriginalBM = (Bitmap)Bitmap.FromStream(fileUploader.PostedFile.InputStream); Size newSize = new Size(300, 500); Bitmap Resizebm = new Bitmap(OriginalBM, newSize); Resizebm.Save(HttpContext.Current.Server.MapPath(yourPath) + yourImage, ImageFormat.Jpeg); OriginalBM.Dispose(); My question is how can i Change Bitmap Resolution and Turn Black & White?

Twain tiff to bitmap

I get tiff image handle frm twain. Now how should I convert it to Bitmap? static FromHbitmap doesnt workstatic internal FromGdiPlus also doesnt work .NET guy

How convert bitmap to Image.source ?

I hold some bitmap object in the memory  ( simple System.Drawing.Bitmap ). I want to make some wpf image control to show this bitmap. I dont want to save the bitmap to the disk and then load it as URI to the wpf image control So, How can i do this simple action ?   Thanks.

How to determine the transparency color in a Bitmap

I think I found out how to set the transparent color in a bitmap. Bitmap.MakeTransparent(Color) But how can I get the transparent color from a bitmap. BTW. I read the term "Alpha Transparency" I'm guessing that that means the alpha values of the pixel colors are not all 255. Is that correct and is that all there is to it? Are there two features in a bitmap? The transparent color and Alpha Transparency. Or are they the same? Thanks in advance  

Dithering problem with Bitmap class

I have a scanned document(black and white in color), which is typed through a word processor. So, I each letter is very crisp in the image and is not overlapping with any other character. But once I load that into Bitmap class I see that because of dithering the words get connected by gray color.   How can i make sure, that when we are loading the image in Image or Bitmap class we can avoid dithering at all. It means that if the system can find the exact color then map it otherwise leave the pixel untouched and dont fill any color(let's say leave it as white).  suneeelid2000@gmail.co

Bitmap casting

Hi, I'm working on a project that manipulate images. I put a Open Dialog Box to load images to the program. After the user choose an especific image my program does something like this: pictureBox1.Image = (Bitmap)image; It works fine with all image format I've tested. Will it work for all image formats? Thanks.

How to get around no Graphics for an indexed Bitmap

I'm building a library of bitmap graphics functions. I'm not sure how to handle the fact that the indexed formats do not allow a Graphics object. I suppose I could check the Bitmap supplied to the function and use the graphics object if it's possible and other methods if it is not. I'm hopping there is a better way. Can you suggest an approach or other helpful comments Also, I've read that GDI+ version 6 allows graphics with indexed data. If that is true is there any way I could make use of that fact?   Thanks
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend