how to write one png image in c++

This is a discussion on how to write one png image in c++ within the C++ Programming forums, part of the General Programming Boards category; hello,I encountered some problems in my homework.I was working on one small software.It's to draw flowchart . I was asked ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    13

    how to write one png image in c++

    hello,I encountered some problems in my homework.I was working on one small software.It's to draw flowchart . I was asked to save my flowchart in png format,but I don't konw how to do it.the file system of png is to hard for me.I am wondering is there exists any library can help me to solve the problem.We cannot coding in c# or using .net.we can only using c++ or some libraries in c++.I was very worry about it ,because the deadline is coming.Can anyone give me any advice.

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,243
    Quote Originally Posted by sfguofen View Post
    hello,I encountered some problems in my homework.I was working on one small software.It's to draw flowchart . I was asked to save my flowchart in png format,but I don't konw how to do it.the file system of png is to hard for me.I am wondering is there exists any library can help me to solve the problem.We cannot coding in c# or using .net.we can only using c++ or some libraries in c++.I was very worry about it ,because the deadline is coming.Can anyone give me any advice.
    You want to use libpng.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    13
    Quote Originally Posted by brewbuck View Post
    You want to use libpng.
    Yes , i konw the library , however , i don't know how to set up the libpng in visual c++ 6.0,would you give me some book or some ur related to setting up the libpng in visual c++

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,475
    Quote Originally Posted by sfguofen View Post
    Yes , i konw the library , however , i don't know how to set up the libpng in visual c++ 6.0,would you give me some book or some ur related to setting up the libpng in visual c++
    You should read the information available to you more closely...


    • Go to libpng homepage.
    • Take notice of the current version (1.2.39)
    • There's a readme section, so you should read it. Clicking on the first link in this section (local website), you'll learn that the file to download for windows is named lbpng1239.zip. You can also download a .7z or a .tar.bz2 version.
    • Going back to the homepage you'll scroll down to the download section, aptly named Source Code.
    • You download the zip version.
    • You open the zip file and read the INSTALL file within. It points you out to the location of the building instructions for windows: projects\visualc71\README.txt if you are using visual studio 2005 or later, or projects\visualc6\README.txt if you are using visual studio 6.0.
    • You follow the instructions
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    Registered User
    Join Date
    Aug 2009
    Posts
    13
    Quote Originally Posted by Mario F. View Post
    You should read the information available to you more closely...


    • Go to libpng homepage.
    • Take notice of the current version (1.2.39)
    • There's a readme section, so you should read it. Clicking on the first link in this section (local website), you'll learn that the file to download for windows is named lbpng1239.zip. You can also download a .7z or a .tar.bz2 version.
    • Going back to the homepage you'll scroll down to the download section, aptly named Source Code.
    • You download the zip version.
    • You open the zip file and read the INSTALL file within. It points you out to the location of the building instructions for windows: projects\visualc71\README.txt if you are using visual studio 2005 or later, or projects\visualc6\README.txt if you are using visual studio 6.0.
    • You follow the instructions
    Thank you , I appreciate your help in setting up the libpng , but now another problem occured , It's that when I press CTRL+F5 to run the Pngtest , an message box about "Please specify the executable file.".It's said that the project need one .exe. but how can I build one executable file.

  6. #6
    Registered User
    Join Date
    Aug 2009
    Posts
    13
    Quote Originally Posted by Mario F. View Post
    You should read the information available to you more closely...


    • Go to libpng homepage.
    • Take notice of the current version (1.2.39)
    • There's a readme section, so you should read it. Clicking on the first link in this section (local website), you'll learn that the file to download for windows is named lbpng1239.zip. You can also download a .7z or a .tar.bz2 version.
    • Going back to the homepage you'll scroll down to the download section, aptly named Source Code.
    • You download the zip version.
    • You open the zip file and read the INSTALL file within. It points you out to the location of the building instructions for windows: projects\visualc71\README.txt if you are using visual studio 2005 or later, or projects\visualc6\README.txt if you are using visual studio 6.0.
    • You follow the instructions
    Thank you again.I have solve the problem, and I can run the pngtest.exe now .

  7. #7
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    You don't need libpng or any lib on Windows (never, api does everything)
    Png is native with Win32 api, like all formats (shell apis and others)

  8. #8
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,475
    Quote Originally Posted by Alex31 View Post
    You don't need libpng or any lib on Windows (never, api does everything)
    Png is native with Win32 api, like all formats (shell apis and others)
    Win32API is a library. libpng is a library. He needs something (eve if it meant writing his own). The option that was offered to him is probably the simplest and easiest to use, since the win32 api comes with a steep learning curve and is overkill for the one and only requirement he mentioned; ability to create a png file.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  9. #9
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by Alex31 View Post
    You don't need libpng or any lib on Windows (never, api does everything)
    Png is native with Win32 api, like all formats (shell apis and others)
    Ew. o.0

  10. #10
    Registered User
    Join Date
    Aug 2009
    Posts
    13
    Quote Originally Posted by Mario F. View Post
    Win32API is a library. libpng is a library. He needs something (eve if it meant writing his own). The option that was offered to him is probably the simplest and easiest to use, since the win32 api comes with a steep learning curve and is overkill for the one and only requirement he mentioned; ability to create a png file.
    O , I have read the manual of libpng , but I think only read the manual is not enough , for example ,png_write_image(png_ptr, row_pointers) , I don't know how the rows is made up .I think i need some examples about , how to draw picture in memory that I can use png_write_image() to save my picture directly

  11. #11
    Registered User
    Join Date
    Aug 2009
    Posts
    13

    how to draw a picture in memory and save it directly by png_write_image() in libpng

    I need to draw one flowchart in memory and save it in the png format . is there are any examples that can help me solve that problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. open read write close
    By mercuryfrost in forum C Programming
    Replies: 7
    Last Post: 08-23-2009, 05:27 PM
  2. image processing
    By ICool in forum C Programming
    Replies: 75
    Last Post: 10-15-2007, 04:42 AM
  3. Displaying a PNG image
    By grep in forum Windows Programming
    Replies: 5
    Last Post: 07-07-2005, 08:27 PM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  5. Some humour...
    By Stan100 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-06-2003, 09:25 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21