473,569 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

save code for a .pnm image editor

1 New Member
hi,

This is my first post in this forum and I just wanted to thank you for even taking a look at my post. The class that I am writing the C code for is my first computer class and my knowledge is limited to what was taught in lectures.

Right now I am making a GUI code and am having trouble saving the image after it has been altered. As of now, the only way that I know how to save is to save over the original picture, but that doesn't even work when I open the new image.

My goal is to not save the new image over the original, but to have a new image file when the save button is pressed. I have no idea where to start.

Thanks again for your suggestions/guidance.

This is what I have so far..


//Save image file (need code)
int SaveFile(HWND window)
{
// Declare local variables
HDC clearing_contex t = GetDC(window);
HWND file_name_box;
char filename[MAXLETTERS];
char savemessage[ MAXLETTERS ] = "Image Saved! please re-load the image";
char imgformatg[80] = "p5";
FILE * outfile;
int count;

// Get the output file's name from the File Text Box
file_name_box = GetDlgItem(wind ow, ID_FNAME); // get file box handle
GetWindowText(f ile_name_box, filename, MAXLETTERS); // get file name from file box

// Open the input file, for writing
outfile = fopen( filename , "w");

// Write-out image information from the input file
fprintf(outfile ,"%s", imgformat);
fprintf(outfile ,"%d", imgwidth);
fprintf(outfile ,"%d", imgheight);
fprintf(outfile ,"%d", imgdepth);

// Write-out the image data from the input file
count = 0;
if (strcmp(imgform atg, imgformat))
{
//for gray scale image
for (row = 0 ; row < imgheight ; row++)
for (col = 0 ; col < imgwidth ; col++)
{
fputc(imgdata[row][col][0], outfile);
count++;
}
}
else
{
//for color image
for (row = 0 ; row < imgheight ; row++)
for (col = 0 ; col < imgwidth ; col++)
for (plane = 0 ; plane < 3 ; plane++)
{
fputc(imgdata[row][col][plane], outfile);
count++;
}
}

// close the output file
fclose(outfile) ;

//clear the background after saving
for (row = 0 ; row < imgheight ; row++)
for (col = 0 ; col < imgwidth ; col++)
SetPixel(cleari ng_context, col+50, row+50, RGB(clear[row][col][0], clear[row][col][1], clear[row][col][2]));

//print out saved Message
SetWindowText(f ile_name_box, savemessage);

return(0);
}
May 2 '07 #1
0 2033

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2102
by: Zviki Goldberg | last post by:
Hi... I am using InkPicture and I would like to save the control (the signature- image) to gif or other image. It will be OK if I could save the WinForm . Is it possible ? Thanks
9
2632
by: Mark Johnson | last post by:
How can you save all or a portion of the Grafics object to a Image/Bitmap ? I am try to save the Images from Cards.dll to a BitMap file. I can read in the Images to the Grafics, but when I try this with a Bitmap the results are Black. Can you somehow Clip the Grafic and Paste it into the Bitmap ? Mark Johnson, Berlin Germany...
0
4121
by: prakash | last post by:
Dear Friends I am new guy to Visual C++.NET I've program to save website as a image vc++.net . It have a function "SaveSnapshot" to save the webpage as an image On that function ifor saving as a image it uses image.Save method() This image.Save function have two overloaded form's first one is file name
4
2840
by: David W. Simmonds | last post by:
Is there a way I can have a button on a ASP.NET form that when clicked will allow the user to save the image to a file on the client side? I know that the user can simply rclick the image and select Save Target as..., but the button might be a more intuitive way.
2
2642
by: Ada | last post by:
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.
4
10230
by: Dale | last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web app and rendering them by using System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF). I am confident that the transparency is working properly because if I save the created image to the local hard disk and then view it in a web page or an image editor, the...
8
19487
by: why? | last post by:
Im working with Python 2.2 on my red hat linux system. Is there any way to write python codes in separate files and save them so that i can view/edit them in the future? Actually I've just started with python and would be grateful for a response. Thanx!
3
4391
by: =?Utf-8?B?Um9nZWxpbw==?= | last post by:
I'm having the wierdest problem. I'm trying to save images into a SQL 2005 database. the field is just called "IMAGES" and hte data type is "image". here is my code to save //following code saves an image as a byte array to a DB string strFn = this.openFileDialog1.FileName; this.pictureBox1.Image = Image.FromFile(strFn); FileInfo fiImage...
3
3094
by: neovantage | last post by:
Hey all, i have created image by mixing logo and the original image. It create image and show in the same window. I have done 3 steps for this. First i upload an image to my server by using move_upload_file, then i resize it using class "thumbnail.class.php" My next step was to embed company logo in it(which i already done) and save new...
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.