|
cedance wrote: where to create classes and why, which i couldnt get a grasp off
If the need for the class functionality is for only once, then you can create an object of the class as local to the function or loop.
But if you want to make use of the same instance many times or in different places or classes then create an object to the class as member to the window/dialog.
cedance wrote: CImage class. Please also point out how to go about using it
You can use CImage or GDI+ Image/Bitmap Class.
Create an instance of any of the above mentuioned class and Load the bitmap of JPEG image and process the image with your written algo.
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
It sounds like you are asking how to design an object-oriented solution to your problem - you know how to program in C, but with this C++ stuff - how should you structure your code, what classes you should design. If this is the case, I'd suggest starting with something simple - I suspect that you will be marked on whether it works rather than on the architecture.
I have only a superficial understanding of the jpeg format, but from memory an image is based around many small pixel blocks (8x8 if I recall). If I am correct, then this sounds like a great little class to write, and an image / file would simply consist of a collection of these blocks. Basically the class would store the pixels, be able to compress / uncompress the data, be able to read / write files and be able to input / output a bitmap. If you wrote this class, say PixelBlock, then the matter of reading a file would be creating and reading in an array of PixelBlocks, displaying on the screen you would simply uncompress each one and convert to a bitmap, you could create a complete bitmap from all the smaller ones, and then apply your filtering, etc... If you allow the size of the pixel block to be a parameter, then the image could be a single pixelblock formed from all the component pixel blocks, you could have your filtering as a member function of the PixelBlock class so you could perform it on blocks or sub-blocks of any size, etc...
Have I given you enough idesa?
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
hmmm... Thanks for the ideas, I will definitely try them out. But, it would be more useful if there are some insights in regard to the current issue, coz this is not graded, i mean i am not taking an exam in this regard. I am asked to program this as a part of my job(HIWI). I have experiences with C and matlab and C++ as u had said, but i am really confused with all the gobbledygooks in this message passing and stuffs associated with MFC in VC++!
thanks a lot,
-cedance
|
|
|
|
|
Sorry, I'm getting a bit confused with your posts, so it seems that your problem is really with windows and MFC. I believe the easiest way into windows is to start with someone's example (i.e. a program that compiles and works) and fiddle with it - learn how to add/change the functionality and understand how it works.
In the help file under CImage there is an example
The SimpleImage sample shows how to use the CImage class to load, display, and save a variety of different image formats, including .bmp, .gif, .jpg, and .png. It shows how CImage can be used to manipulate the image in various ways, and how to extract information about the image. SimpleImage uses the CFileDialog class to present the user with the standard Windows dialog boxes for loading and saving files of various formats. The sample creates a docking toolbar using the CToolBar class. The toolbar displays a set of buttons for resizing the image.
I haven't tried it but it could be a good place to start. Otherwise get one of the other samples or a program from codeproject etc.. and start fiddling!
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
I tried running the samples, when i try to build them it says "0 succeeded, 0 failed, 1 skipped" and i am not able to run the sample program itself!
-cedance
|
|
|
|
|
My samples come setup for Itanium platform, see if the platform is set to Itanium, if it is change it to Win32 (in the toolbar at the top of visual studio).
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
I may not have made it clear in my reply, but I tried this sample and I got the same error. I tracked it down, in my case, as being due to the sample coming up with Itanium configuration selected, changing this to Win32 and then all compiles OK and I can run the sample.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Hallo all,
I make MFC app Dialog form with Visual C++.Net , when i use textbox control there is no OnKeypress, OnKeyDown event available on Class Wizard for this textbox control, how can i make these event available on my Visual C++ project?
When i make app with Visual Basic there is many event onkeypress, onmouseover,onmousekeydown...etc that not available on Visual C++, how can i make these event avalable on my Visual C++ project?
thx for ur help...
|
|
|
|
|
HandyC++ wrote: when i use textbox control there is no OnKeypress, OnKeyDown event available on Class Wizard for this textbox control
B'coz no need for those events for Edit Control. But if you want to process those message, then
1) Derive a custom Edit control class and Handle the WM_KEYUP,WM_KEYDOWN messages
or
2) Override PreTranslateMessage method of your dialog and check for your Edit Control messages
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
Great, i will try it, thnx u
|
|
|
|
|
How do I display rows of text?
CString testString;
testString = "Test!";
testString +="\r\n";
testString +="Test Again";
pDc->TextOutA(0,0,testString.GetBuffer(),testString.GetLength());
testString.ReleaseBuffer();
This displays text as
Test!||TestAgain.
And not like
Test!
Test Again
What should I do? Also, when I'm reading text from file, how do I control the newline?
----------------------------
286? WOWW!
|
|
|
|
|
_8086 wrote: pDc->TextOutA
Use DrawText instead of TextOut .
|
|
|
|
|
----------------------------
286? WOWW!
|
|
|
|
|
I need to change some CTreeCtrl properties in run Time.
For example - when my application is start i need to check if the CTreeCtrl is appearance as "check boxes = true" and if its not so convert it to true.
I don't find any function that i can use in this case.
Someone can help me ?
Thanks.
|
|
|
|
|
Use GetWindowLong(..) API and check for TVS_CHECKBOXES flag.
Modified...
To set the flag use SetWindowLong(..) API, as below
LONG lStyle = GetWindowLong(treeHandle, GWL_STYLE);
if (! (lStyle & TVS_CHECKBOXES))
{
lStyle |= TVS_CHECKBOXES;
SetWindowLong(treeHandle, GWL_STYLE, lStyle);
}
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
Could somebody give detail about how to use states and action in listbox control in DrawItem?I don't know how to combine the state and action to get result what I want.I have refered to many examples,but different examples have different combination.Help~~~~
|
|
|
|
|
IT_DOER wrote: states and action in listbox control in DrawItem
Action defines the drawing action required. If selection is the action being done then it will be ODA_SELECT, now you need to check whether it's Selection or de-selection.
If it's selection then the state bit will be set to ODS_SELECTED else it will be off.
The same principle is to be followed for the rest of the action items.
|
|
|
|
|
Q1:
if(action&ODA_FOCUS)
{
CBrush brush(RGB(255,0,0));
pDC->FrameRect(&rectItem,&brush);
}
I wonder why I do this in DrawItem,when I ran the program and clicked the item which is not the first one,the first item's edge turned red too?
Q2:
What is difference between ODA_FOCUS and ODA_SELECT?
Q3:
As I click an item in a listbox,and then I click another control,does combination of (state & ODS_SELECTED)&& !(action&ODA_FOCUS) correspond to the item I clicked firstly?
|
|
|
|
|
Im working on a piece of code that stores objects and manages subscriptions to these objects, each object can have multiple subscriptions and each subscription can relate to multiple objects. Both objects and individual subscriptions are identified by an int ID
I have an STL map of MyObjects keyed by their integer id
std::map< int, MyObject > mObjects;
I have an STL map that maps an object id to a list of subscription id's that relate to that object
std::map< int, std::set< int > > mSubscriptions; subscription list by object id
I get passed a subscription id to remove. What I need to do is look at the mSubscriptions map and remove each occurance of the subscription id. Then if any object is left with zero subscription id's I need to remove it from the mSubscriptions map all together and remove the object from mObjects map.
I can do this with a few loops but I'm sure it could be done better by using std::remove_copy_if() to remove the subscription id from mSubscriptions and return a vector of the object id's that now have no assosiated subscriptions. I could then use that vector of object id's to remove them from mObjects
Can anyone give me a few pointers on how to code the predicate to pass to std::remove_copy_if() to achieve this?
What I'm having trouble with is the fact mSubscriptions::value_type is a pair< > and I want to copy the .second member into my vector
-- modified at 22:21 Sunday 25th March, 2007
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
While this might not be immediately helpful you might want to consider using Boost’s Multi-index[^] containers library for this kind of thing.
Steve
|
|
|
|
|
Stephen Hewitt wrote: While this might not be immediately helpful you might want to consider using Boost’s Multi-index[^] containers library for this kind of thing.
Thanks mate,
I like the boost stuff but only a subset of it is approved for use here.
I eventually found out that I should be using std::map::erase() not std::remove_copy_if() as remove_copy_if() and remove_if() dont support map becauase its value_type is a pair<> and the first element of the pair is always const which prevents these functions from being able to copy elements of the collection
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
As I understand it you’re looking up based on subscription id: that's the set mapped to below (underlined):
std::map< int, std::set< int > > mSubscriptions; subscription list by object id
If this is the case it's a little strange on the face of it. A map only gives logarithmic performance mapping in one direction: you seem to be mapping in the opposite direction. Perhaps this is intentional because the operation is infrequent? Or perhaps I'm misunderstanding the question?
Steve
|
|
|
|
|
Stephen Hewitt wrote: you seem to be mapping in the opposite direction.
yep
Stephen Hewitt wrote: Perhaps this is intentional because the operation is infrequent
The two requirments are that a client can get a reference to the object map (mObject) without seeing the subscription information and that inserts and updates to this and the subscription info are as fast as possible
The guy that wrote the original version has a very different structure that used a call to std::transform() to return a copy of the object map. This was hugely inefficient as each instance of MyObject was copied by value several times per call
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
Josh Gray wrote: I like the boost stuff but only a subset of it is approved for use here.
Out of curiosity what libraries are in that subset?
Steve
|
|
|
|
|
at the moment we have
boost::test
boost::regex
boost::tokenizer
boost::function (signal is banned, im told this is because it can be very slow)
boost::bind
boost::thread
boost::lexical_cast
This is the first place I've worked that has used it and I really like it. I dont know the details but there was a major stuff up once many moons ago that caused the powers that be to ban all use of third party libs without expicit approval.
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|