.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

Why Image.save creates a black image

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
Hello, I am trying to create a screenshot, here is the code, it creates a complete black image.Thanks for any help. Public Function CaptureWindow(ByVal handle As IntPtr) As Image               ' get te hDC of the target window               Dim hdcSrc As IntPtr = User32.GetWindowDC(handle)               ' get the size               Dim windowRect As New User32.RECT()               User32.GetWindowRect(handle, windowRect)               Dim width As Integer = windowRect.right - windowRect.left               Dim height As Integer = windowRect.bottom - windowRect.top               ' create a device c

View Complete Post

More Related Resource Links

image.save not saving images


I have a piece of code that writes string into an image and save it. It works on one of my site and but not the other. The image.save is not working. If this is a permission problem, which account should I change? I use win server 2003 and IIS 6, and have given ASPNET, NETWORK SERVICE, and anonymous user write access.

Getting generic GDI error when trying to save resized image

Getting following error:A generic error occurred in GDI+.
Any help is appreciated.
Public Sub SaveImageFile(ByVal sourceImage As Bitmap, ByVal saveImagePath As [String], ByVal maxImageWidth As Integer)
            ' Resize if source image width is greater than the max:

            If sourceImage.Width > maxImageWidth Then
                Dim bmp As Bitmap = TryCast(sourceImage, Bitmap)
                Dim newImageHeight As Integer = CInt(Math.Truncate(sourceImage.Height * (CSng(maxImageWidth) / CSng(sourceImage.Width))))
                Dim gr As Graphics = Graphics.FromImage(bmp)

                Dim bmpnew As New Bitmap(maxImageWidth, newImageHeight)
                gr.InterpolationMode = InterpolationMode.HighQualityBicubic

                gr.DrawImage(bmpnew, 0, 0, maxImageWidth, newImageHeight)

                'code to manipulate bmpNew goes here.



Insert image into Infopath form and save to SharePoint as PDF file


I have an InfoPath web-enabled form in MOSS 2007, that is integrated with a K2 blackpoint process for an approval workflow.

Once the form (a Purchase Order request form) has been approved in the K2 workflow process, I switch the form view to a "print-friendly" view for the requestor to view from the browser.  However, now I need to go one step further with this scenario:

1) I need to somehow insert/embed an image with the scanned-in signature of the approver (likely stored in a SP doc library) at the signature line section of my form.  Also, what are the security requirements for storing such images, but not granting all users access to these (e.g. only services accounts that need to access this for embedding into the form, etc.)?

2) Then I need to convert this final "print-friendly" view of the form (with the signature image) to a PDF document so that I can store it in SharePoint (and email it to the requestor using K2's email event capabilities).

Can anyone help me with a solution to both of these requirement, or point me to some resources for this (even 3rd party components are open-game).



"Save as image" available programatically?

Hi,With the rehosted designer it is possible to right click in the design area and choose to save the workflow as an image. This is cool functionality and was wondering if it was possible to call this programatically? This would then allow me to show an image of what the workflow looks like without having to load up the full designer.Does anyone know if this is possible or how it can be done.ThanksMatt

Visual Studio Extension: Save UML diagram as image

I am auditing one big legacy application. I use Visual Studio 2010 modeling projects to visualize the design of this legacy application. When I wanted to get my UML diagrams to image files so I can insert them to documents I found no option for it. As it turned out we have to write extension for modeling projects and deploy it as Visual Studio 2010 extension. Here is the installer and source package of my UML.SaveAsImage extension. UML.SaveAsImage.zip VS2010 solution | 48KB UML.SaveAsImage.Install.zip VSIX insaller | 4KB I still cannot believe that we need to write extensions to get our UML diagrams to image files but okay, it's done now and let's say - problem is solved. At least this one. In my work I used code example by Cameron Skinner. He has very good blog posting titled as Save a diagram to Image File. Here are steps how I wrote this extension. 1. Create new Layer Designer Command Extension project As a first thing you should create layer designer command extension project. If you don't have support for modeling projects you should take more powerful edition of Visual Studio 2010. Name it your project as you like and click OK. 2. Add functionality to Command class You can find Command class from your new project. This class is created by default. Here is the modified code from Cameron Ski

Winnovative:Could not save image. Parameter is not valid.

while running website,the image get extracted from pdf document but still an exception named pdfimgextractexception appears at the end of an application.please give me the solution regarding this problem. code as follows: pdfImgExtractor.ExtractImages(srcPdfFile,true); which calls an eventhandler: pdfImgExtractor.ImageExtractedEvent += new ImageExtractedEventHandler(pcmd.pdfImgExtractor_ImageExtractedEvent); where the definition is: {   try { System.Drawing.     ographics = ographics.DrawImage(extractedBitmap, extractedBitmap.Dispose(); extractedBitmap = obitmap;     ographics.DrawString( ographics.Dispose(); ofont.Dispose(); oBrush.Dispose(); extractedBitmap.Save( extractedBitmap.Dispose(); }   {   }   Bitmap extractedBitmap = args.ExtractedBitmap;Graphics ographics;Bitmap obitmap = new Bitmap(extractedBitmap.Width, extractedBitmap.Height);Graphics.FromImage(obitmap);new Rectangle(0, 0, obitmap.Width, obitmap.Height), 0, 0, extractedBitmap.Width, extractedBitmap.Height, GraphicsUnit.Pixel);SolidBrush oBrush = new SolidBrush(Color.Black);Font ofont = new Font("Arial", 8);"Some text to write", ofont, oBrush, 10, 10);"D:\\example.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);catch (Exception err)HttpContext.Current.Response.Write(err.Message); } thanks in advance.

ASP.NET: How to Load image and save to database form clientside

Hello, can any one help? I am using HTTPHandlers for loading the image from the database I need to change the image and save it back to the database from the client side, that is I need to browse image at client side and save the image as bytes in to databases, how to do this? Regards, satish  

save image to PC directory


i don't know why when i  save the same picture to the same directory,it causes the error message: "A generic error occred in GDI+"??????
but if i change another picute to save , it works properly

my code is as belows:
 Image img = Image.FromFile(this.picBox2.ImageLocation.ToString());
img.Save(@"D:\Temp\111.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);

how can i prevent this error when i save the same picture?

save image in new folder


i have a image which i am picking from open file dialog now i want to save image in my project folder

please hep me

Binary Data Problem....save and retrive image data from sql database


hello friends...please help me to solve this problem....

i have created crud (create, retive, update and delete)form and it's running... here i want to add images for each record(sql database)....

i'm using image datatype in sql table for picture.....

Q 1: how to save and retrive binary data(image) from sql table in asp.net form using vb coding?

Q2: can i create sql table which store binary(image url) data direct?

thank you

Save Clipboard image as an attachment?


Does anyone know of a solution to save a clipboard image as an attachment (jpg) to a New Form? Basically the ability to save screenshots as an attachment.


How to save WPF RichTextBox content (text + image) to the database



I want to save (and after that also to retrieve) the content of an WPF RichTextBox (text + image) to/from the database.

I found this: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/750a654e-b002-4742-8f46-609e93f6ec81 but like the author said, the solution seams not to work for text with image - the image is ignored/removed and only the formatted text is saved and after that retrieved to/from database.

Know someone a solution about this issue?

Best regards,





LIst box image Item -Rotate and save the rotated image to disk

<Window x:Class="DataBindingListBox.Window1"




 Title="Window1" Height="775" Width="1285" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow">


  <DataTemplate DataType="{x:Type MySample:Photo}" >   

   <Border Background="White" BorderBrush="#22000000" BorderThickness="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

    <Grid Name="ListItemGrid" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2" ShowGridLines="True" Background="Transparent">

     <TextBlock ></TextBlock>

     <!-- Drop Shadow -->

     <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CornerRadius="4" Background="Brown">


       <TranslateTransform X="2" Y="2" />




Save Image in table



I have the huge table that each record has an image. My question is: Do saving image in the table (Image Column) is good way? Or you have better way?

Of course, if I save image in table I will create new table for images and make relation between them.

Best regards. Morteza

Image appears black


I try to create an image with alternate black and white pixels using following code.but i couldn't able to create desired result.i don't know what is wrong in my logic kindly help me


Dim cr As New Bitmap(4, 4)

cr.SetPixel(0, 0, Color.Black)       

cr.SetPixel(0, 1, Color.White)

cr.SetPixel(1, 0, Color.White)

cr.SetPixel(1, 1, Color.Black)       

Prvwbox.Image = cr

Getting a black image when creating thumbnail


I'm trying to save two images to the DB, the original image and a thumbnail of the original.

But all I'm getting is a black image :/
I'm also trying to keep the proportions of the original image when creating the thumbnail, and I hope I'm right.

System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
decimal w = img.Width, h = img.Height;
int newHeight = 0;

// Keep proportions of thumbnail if width is above 120px
if (img.Width > 120) newHeight = (int)((w / h) * 120); else newHeight = img.Height;

System.Drawing.Image thumb = new System.Drawing.Bitmap(120, newHeight);
MemoryStream ms = new MemoryStream();
thumb.Save(ms, img.RawFormat);
Byte[] bytesThumb = ms.ToArray();

FileUpload1.PostedFile.InputStream.Seek(0, SeekOrigin.Begin);
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
sqlParam = cmd.Parameters.Add("@thumb", SqlDbType.VarBinary, -1);
sqlParam.Value = bytesThumb;

sqlParam = cmd.Parameters.Add("@data", SqlDbType.VarBinary, -1);
sqlParam.Value = bytes;

Thanks in advance!


saving WPF inkCanvas to image makes black background



i am saving inkcanvas but it saves black image




rtb = new RenderTargetBitmap<

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