?
Solved

Manipulate an image using c++(MFC)?

Posted on 2000-04-05
9
Medium Priority
?
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 800 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

771 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