Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Image processing in C

Image processing in C

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
10 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ravi Shanakar Singh
    wrote on last edited by
    #1

    Can anyone suggest me, how to implement program that break (.png) image in two equal part?

    J enhzflepE CPalliniC L 4 Replies Last reply
    0
    • R Ravi Shanakar Singh

      Can anyone suggest me, how to implement program that break (.png) image in two equal part?

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      Use a library that supports reading and writing PNG files. When reading you will get an uncrompressed bitmap in memory that can be modified and written again. In your case just create two new bitmaps by copying the areas of interest from the input bitmap. But there are existing command line tools that can do what you want. An example is ImageMagick: Convert, Edit, Or Compose Bitmap Images[^] (see crop at ImageMagick: Command-line Options[^]). See Fred's ImageMagick Scripts: SPLITCROP[^] for a small script that will do what you want.

      1 Reply Last reply
      0
      • R Ravi Shanakar Singh

        Can anyone suggest me, how to implement program that break (.png) image in two equal part?

        enhzflepE Offline
        enhzflepE Offline
        enhzflep
        wrote on last edited by
        #3

        If you're able to, you really should consider leveraging c++ for this task. Doing so allows you to use functionality built into windows for well over a decade - GDI+. GDI+ allows one to read formats windows supports natively, also including methods that facilitate the saving of bitmap images to files on disk.

        L 1 Reply Last reply
        0
        • R Ravi Shanakar Singh

          Can anyone suggest me, how to implement program that break (.png) image in two equal part?

          CPalliniC Online
          CPalliniC Online
          CPallini
          wrote on last edited by
          #4

          You might use a library, or, as others suggested, GDI+. The natural way for accessing GDI+ is using C++. However it exposes also a (not recommended) flat API[^].

          In testa che avete, signor di Ceprano?

          L 1 Reply Last reply
          0
          • enhzflepE enhzflep

            If you're able to, you really should consider leveraging c++ for this task. Doing so allows you to use functionality built into windows for well over a decade - GDI+. GDI+ allows one to read formats windows supports natively, also including methods that facilitate the saving of bitmap images to files on disk.

            L Offline
            L Offline
            leon de boer
            wrote on last edited by
            #5

            He has asked for C and he said nothing about Windows so why bring up Windows/GDI ... You need to remember not everything that is requested is for a PC and often not on Windows. It's highly possible he doesn't have a C++ compiler available or even as an option for what he is working on. There is a very large embedded industry out there and almost none of those micro-controllers and processors have a C++ compiler available. Don't make assumptions about what he is doing.

            In vino veritas

            enhzflepE 1 Reply Last reply
            0
            • CPalliniC CPallini

              You might use a library, or, as others suggested, GDI+. The natural way for accessing GDI+ is using C++. However it exposes also a (not recommended) flat API[^].

              L Offline
              L Offline
              leon de boer
              wrote on last edited by
              #6

              Same comment as above the poster said nothing about being on Windows. Why would you assume he has it available? He asked to split a PNG file with C code that was it.

              In vino veritas

              CPalliniC 1 Reply Last reply
              0
              • R Ravi Shanakar Singh

                Can anyone suggest me, how to implement program that break (.png) image in two equal part?

                L Offline
                L Offline
                leon de boer
                wrote on last edited by
                #7

                Okay so in C you will find references to libpng which was done for a computer book all over the internet, it is a platform-independent library that contains C functions for handling PNG images that is 20 years old. Technically the code is ANSI C (C89) which should run on most C compilers even those for micro-controllers. It isn't bad and easily understandable. You will often find more up to date conversion of the original code but it's more often you will run across the read implementation than the write. The code to use the png library isn't hard as you will see A simple libpng example program[^] You download the png library from the pnglib homepage libpng Home Page[^] There are manuals and "howto" instructions and pages there.

                In vino veritas

                1 Reply Last reply
                0
                • L leon de boer

                  Same comment as above the poster said nothing about being on Windows. Why would you assume he has it available? He asked to split a PNG file with C code that was it.

                  In vino veritas

                  CPalliniC Online
                  CPalliniC Online
                  CPallini
                  wrote on last edited by
                  #8

                  Because this is the C/C++/MFC forum. It is just a guess, anyway.

                  In testa che avete, signor di Ceprano?

                  1 Reply Last reply
                  0
                  • L leon de boer

                    He has asked for C and he said nothing about Windows so why bring up Windows/GDI ... You need to remember not everything that is requested is for a PC and often not on Windows. It's highly possible he doesn't have a C++ compiler available or even as an option for what he is working on. There is a very large embedded industry out there and almost none of those micro-controllers and processors have a C++ compiler available. Don't make assumptions about what he is doing.

                    In vino veritas

                    enhzflepE Offline
                    enhzflepE Offline
                    enhzflep
                    wrote on last edited by
                    #9

                    Simple. He didn't explicitly say they would be no good. CodProject is, as you're no doubt fully aware, an MS-centric site. It's also not uncommon for new members to be less explicit than would be beneficial. I don't need to remember anything pal. I'm fully aware that plenty of articles here are for Arduino projects. No-poop sherlock. I've spent time in it myself. Go back and read my post, ya dolt. Here, I've saved you the trouble. I even highlighted the important parts you seemed to have made your own assumptions about. If you're able to, you really should consider leveraging c++ for this task. The only assumption I made was that all offerings of help made in good faith would be gratefully received - not necessarily useful, but received gratefully all the same. Go and get a dog up ya

                    L 1 Reply Last reply
                    0
                    • enhzflepE enhzflep

                      Simple. He didn't explicitly say they would be no good. CodProject is, as you're no doubt fully aware, an MS-centric site. It's also not uncommon for new members to be less explicit than would be beneficial. I don't need to remember anything pal. I'm fully aware that plenty of articles here are for Arduino projects. No-poop sherlock. I've spent time in it myself. Go back and read my post, ya dolt. Here, I've saved you the trouble. I even highlighted the important parts you seemed to have made your own assumptions about. If you're able to, you really should consider leveraging c++ for this task. The only assumption I made was that all offerings of help made in good faith would be gratefully received - not necessarily useful, but received gratefully all the same. Go and get a dog up ya

                      L Offline
                      L Offline
                      leon de boer
                      wrote on last edited by
                      #10

                      I have no idea why you feel the rant is necessary .. I have referred it to admin I found your comment strange for the following reasons, so we are clear 1.) The original PNG library was written in C and is still maintained (20 years so far) 2.) It's dubious there is any advantage on converting PNGLIB to C++ you are just likely to get bugs any C++ compiler can compile PNGLIB anyhow 3.) The OP said nothing about windows 4.) Even if you are on windows the GDI+ does not support PNG because it is licenced .. SEE => PNGLIB. Even IPicture which support JPG and GIF does not support PNG. So you would still have to write your own GDI+ extension code. There is no malice intended, I just think your advice was misguided for the above reasons. Now if I am in error on any of those points then please let me know.

                      In vino veritas

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups