Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Manipulate an image using c++(MFC)?

Posted on 2000-04-05
9
Medium Priority
?
204 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
Technology Partners: 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 clear a vector as well as how to detect empty vectors in C++.

604 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