Thread: Resize Image File???

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    193

    Resize Image File???

    I am trying to resize an image in C++ if it can be done. I am using Dec-C++. Here are some questions I have:

    1. How do I get an images Width & Height with C++?

    2. How do I resize the image to any desired Width & Height?

    Thanks for any help in advance and sorry if I'm asking for too much.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Depends on the image type.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    To be a bit more specific. Images are stored in various formats. BMP, the typical Windows Bitmap. GIF, the CompuServe image format. JPEG, the Joint Picture Experts Group's image format. PNG, the Portable Network Graphic. The list goes on and on, but these four are probably the most common.
    Each format is completely different and thus needs to be read and written in its own unique way.

    Once you have the image data read, you have to resize it. For making the image smaller, this means cutting pixels out or combining several into one. For making the image larger, this means adding pixels.
    There are many algorithms to do these things. Usually, the better the quality of the resizing, the slower the algorithm.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    the bottom line is, the C++ standard does not include any specification for image manipulation (and probably never will). you will have to either research the target file format and develop your own processing techniques or else locate a suitable third-party library to handle the low-level stuff.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Registered User
    Join Date
    Aug 2004
    Posts
    193
    Thanks for the info. I am resizing jpg images if that makes any difference.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM