Solved

Manipulate an image using c++(MFC)?

Posted on 2000-04-05
9
190 Views
Last Modified: 2010-04-02
I need to write a program in c++ using MFC to read an image file and then shifting the first few columns of the image data ie removing them and adding same number of columns(black) at the end.
0
Comment
Question by:Barry01
  • 5
  • 4
9 Comments
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2688953
// column between x1 and x2 are skipped

for(int row=0; row < rowcount;++row)
{
   
   for(int col=0, out=0; col < colcount; ++col)
   {
     if(col<x1 && col > x2 )
       image_out[row][out++] = image_in[row][col];
   }
}
0
 

Author Comment

by:Barry01
ID: 2690436
First I want to read the color image and then store it.
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2692579
1. Do you know how to load the image from disk to memory?
2. What type of image file, eg., .bmp, .tif, .tga, .gif etc...?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Barry01
ID: 2693932
NO I don't know
the image file is tif
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2699481
Tiff is Tough

You can find specification on the format at: http://www.wotsit.org/

If possible, use an easier format. Tiff can handle a huge variety of image types, various compression schemes etc... All these variations make it vaery hard, though the basic format is very elegant.
0
 

Author Comment

by:Barry01
ID: 2702229
How to read the file if I convert the image into ppm or bmp format?.
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2703463
Mhh, .bmp would probably be easier under Windows, still, manipulating them is quite tedious. On the other hand, Windows bitmaps are stored in a way much similar to the layout when used in memory, there maybe be an easy way to load and use them directly, I'd have to look some things up.

Basically you would
A - load the bitmap from file into a suitable memory based format.
B - create a window
C - Set the bitmap bits to the window's client device context.
0
 

Author Comment

by:Barry01
ID: 2704771
one last question
SUppose I am reading two images using
fread(...)
and assigning all the bytes of the second image that are similar to the first one to zero(0).
I get the image back and adding the value of the that byte by adding the same value of the first image.

BUt let's suppose if I also assign those bytes which have difference of 1 in particular byte to 0. then I don't get the image back to it's original value.

0
 
LVL 7

Accepted Solution

by:
KangaRoo earned 200 total points
ID: 2706825
Thers is at least a problem with the first statement. To restore the second image you would have to replace all 0's with values from the first, on the assumption that these were set to 0 because they equalled the value in the first image. But if 0 is a legal value in a normal image (let's say black) then all 0's will be replaced, including those that were 0 before any replacements were made.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question