|
If you're using C++ , an option maybe usign STL constainers, for instance a vector :
std::vector <A> v;
A a;
while (fread(&a, sizeof(a), 1, ptr_myfile) != EOF)
{
v.push_back(a);
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi Friends
CImage img;
img.Load (" 1.jpg ");
img.save ("2.tif",Gdiplus::ImageFormatTIF);
its converting the image jpg to tif. but i need to convert with out comparession mode ..how to do it ??
thanks
Raju
Failure is Success If we learn from it!!
|
|
|
|
|
You've to use directly GDI+ Image (CImage is just a wrapper of) class for that purpose , I suppose.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Use BMP, unless set for RLE, it uses no compression whatsoever.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Hi To All,
I have written a code to write some data to a binary file system ...(I am writing 3 structure with different size)...one after another. like A,B,C
I dont have any delimiter or special object to know the next size(bytes) to read from the file .
Because of that I always read one by one....
Now I want to overwrite the middle structure...(B).....While over writing I am having some problem...
what I did is...
...Read the file with size of A (in order to point the file pointer to the next memory..ie starting of struct B)...then write the second structure with the sizeof(B)...
I have open the file in r+b mode....
Now when I read the file its showing some error
please help me for the same...
-----------------------------
I am a beginner
|
|
|
|
|
What about:
- Read the whole file into the three variables.
- Modify the intended variable(s).
- Write again all the three variables to the file.
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I guess thats the easiest method, it dint strike my head...Hehe
Thanks anyway,
But for my knowledge I wanted to know, if we can do the other way....
-----------------------------
I am a beginner
|
|
|
|
|
Yes, of course, you may do it the other way: post your code if you need help about.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Theoretically, it is the right thing you've done concerning the write part. However, when reading your file again you encounter an error.
We need source code here.
Easy Profiler : Now open source !
http://www.codeproject.com/KB/cpp/easyprofiler.aspx
|
|
|
|
|
sorry...its not error,...but its some junk values...
-----------------------------
I am a beginner
|
|
|
|
|
Yes I know.
What I meant by "encountering an error" is the fact that you get unexpected values when you re-read your file, while, theroetically, you should get the same as updated by the write operation.
Easy Profiler : Now open source !
http://www.codeproject.com/KB/cpp/easyprofiler.aspx
|
|
|
|
|
I advise you not to surrender. You could be doing some mistake in manipulating the IO routines that you would commit again have you decided to embark into a new method.
Easy Profiler : Now open source !
http://www.codeproject.com/KB/cpp/easyprofiler.aspx
|
|
|
|
|
i guess the new method would be very simple..i think i will adopt that.
-----------------------------
I am a beginner
|
|
|
|
|
hrishiS wrote: Now when I read the file its showing some error
We cannot guess what this is; if you get an error then put the details here so someone can help you.
|
|
|
|
|
oh sorry for the miss interpreting...its not error,...but its some junk values...
-----------------------------
I am a beginner
|
|
|
|
|
hrishiS wrote: ...Read the file with size of A (in order to point the file pointer to the next memory..ie starting of struct B).
-just an...hmm, how to say..."architectural" note here, you can use seeking (fseek[^], CFile::Seek[^], don't know how you work with your file) to position the file pointer, so if you know that your file contains A B and C in this order and you know their sizes you can position the file pointer at the beginning of B by seeking from the beginning of the file to sizeof(A) position, this way you don't need to read the A struct and can save up on speed and memory, i know this doesn't really make much of a difference when your structs are small.
After wirting to the file, did you close it and reopen it and then read A and B (and maybe C) to check the result of your previous write? If you are doing the writing and then reading of your B structure "in the same session", without closign the file, did you seek back to the start of the B structure before reading?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I am having a jpeg image & ia want to make it as a icon for my dialog based application.My application has multiple diloag.when i tried to copy my image & paste in the icon i am nt gettng the proper image.
|
|
|
|
|
It seems your icon editor is not supporting all the colors in your jpeg image. May be you can use an image dititor like Photoshop or GIMP (it is free)to create your icons from the jpeg image.
|
|
|
|
|
Additionally to what Rejeesh said, i recommend IcoFX[^], it's free and it is quite good and easy to use.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I do not know if this is the right place to ask this question but,
I have written a windows service which polls serial port for serial activity and an input device writes out the port with some time interval. In other words, whenever a write occurs, the service reads and process that and make available to another program.
Since it would be a waste of time and resource to poll the port all the time, i was starting the service when the main application is running and stopping it when the program exits. However, this scenario does not work for Windows7 and i could not test it but probably for vista as well.
I used OpenSCManager with CONNECT but cannot open the service with SERVICE_START or SERVICE_STOP privilege.
any idea, how can this be solved? (I am currently reading some UAC stuff but have not found something yet)
Best Regards
|
|
|
|
|
Hi im setting the size of dialog as follow:
void CToolBarDlg::OnWindowPosChanging(WINDOWPOS* lpwndpos)
{
CDialog::OnWindowPosChanging(lpwndpos);
// TODO: Add your message handler code here
SetWindowPos(&CWnd::wndTop,0,80,400,900,SWP_NOSIZE);
}
I have one button in dialog..when i press that,im going to width of the dialog. so on that button function i used SetWindowPos as follow
void CToolBarDlg::Onchangesize()
{
SetWindowPos(&CWnd::wndTop,0,80,100,900,SWP_NOSIZE);
}
But it show assertion error on SetWindowPos() on winocc.cpp
Whats my mistake and how can i change the width of dialog.
Anu
|
|
|
|
|
You can change the size of your dialog from OnInitDialog() function.
SetWindowPos(&wndTop, 0, 0, 150, 150, SWP_NOMOVE);
|
|
|
|
|
when i set the pos in OnIntiDialog(),it doesno t work.I asked this doubt previously in codeproject.then only i used that in Onwindowposchanging().
Now i want to reduce the wodth of dialog after pressing the button.
Anu
|
|
|
|
|
When SWP_NOSIZE is used with SetWindowPos() the width you are specifying is ignored. Remove SWP_NOSIZE and see.
|
|
|
|
|
But its not working.Same assertion error.
Anu
|
|
|
|