472,331 Members | 1,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 software developers and data experts.

GDI+ and SAVE JPG or BMP on the server

Ada
First of all, I thought this might be a directory security issue but it's not.
I was able to upload the file to the directory via HTTP.

Here's the situation.
I have a JPG file on my server.
..../images/myPIC.jpg

I wanted to draw a box or line using GDI+ on top of myPIC.jpg and then save
the new image to the server.

I was able to draw and display the image on screen but somehow cannot figure
out how to save it to the server.

The code below allows the result to be displayed on screen and it works fine.

newBMP.Save(Response.OutputStream, ImageFormat.Jpeg);

Something else is strange with the above image. When I RIGHT-CLICK and
attempted to save the image, the image cannot be saved. Although it displays
on screen but somehow I cannot copy the image using the RIGHT-CLICK.

Below is the code I used to save the image to the server....

newBMP.Save(Server.MapPath("images/" + "myNewPIC.jpg");
Got the following error:

[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +578
System.Drawing.Image.Save(String filename, ImageFormat format) +59
System.Drawing.Image.Save(String filename) +24

Mar 19 '06 #1
2 2567
> [ExternalException (0x80004005): A generic error occurred in GDI+.]

99.9% of the time, when using GDI, 'a generic error occured' means that the
directory you are trying to save to doesn't ahve the proper permissions.
Typically, you need to make sure that directory is allowing asp.net to
modify files.

-Darrel
Mar 20 '06 #2
Ada
That's what I thought so.
However, I was able to upload file to the directory.
If dir permission doesn't allow READ and WRITE, I would think I wouldn't be
able to upload anything there.

If I added IMAGE control to the web form and allow the result to display in
the IMAGE control, the same SAVE code works.

My goal is that I don't want to display the result on screen.
The practical application would be something like a WATERMARK.
May be I have a TEXTBOX control and allow the ASP.NET and GDI+ to draw a
string on an image(s).
And if necessary, display the result on screen plus save the same result on
the server.


"Darrel" wrote:
[ExternalException (0x80004005): A generic error occurred in GDI+.]


99.9% of the time, when using GDI, 'a generic error occured' means that the
directory you are trying to save to doesn't ahve the proper permissions.
Typically, you need to make sure that directory is allowing asp.net to
modify files.

-Darrel

Mar 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Nathan Sokalski | last post by:
I am trying to create graphics with GDI+ that include transparency. However, the transparency never seems to show up, even though my colors have an...
2
by: Alphonse Giambrone | last post by:
I am currently reading 'Programming The Web with Visual Basic .NET' and have so far found it to be excellent. Downloaded all the code from Apress...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! ...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.