Solved

Manipulate an image using c++(MFC)?

Posted on 2000-04-05
9
185 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
Comment Utility
// 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
Comment Utility
First I want to read the color image and then store it.
0
 
LVL 7

Expert Comment

by:KangaRoo
Comment Utility
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
 

Author Comment

by:Barry01
Comment Utility
NO I don't know
the image file is tif
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Expert Comment

by:KangaRoo
Comment Utility
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
Comment Utility
How to read the file if I convert the image into ppm or bmp format?.
0
 
LVL 7

Expert Comment

by:KangaRoo
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now