Solved

Manipulate an image using c++(MFC)?

Posted on 2000-04-05
9
186 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
 

Author Comment

by:Barry01
ID: 2693932
NO I don't know
the image file is tif
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

911 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

19 Experts available now in Live!

Get 1:1 Help Now