|
John R. Shaw wrote:
You've were talking about reading a structured file one byte at a time. Which impilies you need to decipher those bytes (complicated, may be need for cross platfom).
It's not that bad. For instance if I need to get the bitmap type, the "BM", I read in a character into a short, then shift the bits left 8-bits, then logically or that variable with the next character. When I read in an integer (4-bytes), I call the previous statement twice, and shifting by 16 bits in between the two calls. I do read in both headers and jump to that location (0x436) but every single 8-bit bitmap file always begins data at that same address so in the interest of simplifying the explanation, I just said I would always go to that byte offset.
John R. Shaw wrote:
... the moment the bitmap type is changed, yout code will fall apart.
I have conditionals in the right places to make sure the file that's read is of the right type, bit depth, size, etc....
Of course, all of this you've brought up is a non-issue because I have no problems reading the bitmap headers, only when I get to that particular location.
I looked at another reply from rateep and he pointed out the problem with a very concise on-topic response to my problem and it fixed my problems.
|
|
|
|
|
Show us your code and we might be able to help...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Well, it's kind of spread out, but I can put the relevant parts back together. I have a class that doles out the data to the function I'm trying to use it in. It's pretty standard file pointer things and I've used file pointers exclusively in the past on countless programs.
Here's some code snips:
CBitmapFile::CBitmapFile(CString fileName) {<br />
bmpFP = fopen((LPCTSTR)fileName, "r");
Where bmpFP is a member variable in CBitmapFile.
Here's the function that I call to get data:
BYTE CBitmapFile::GetNextByte() {<br />
BYTE data;<br />
data = getc(bmpFP);<br />
nBytesRead++;<br />
nVerticalPosition++;<br />
nCurrentPosition = ftell(bmpFP);<br />
return data;<br />
}
I used fscanf, I'm trying to use file streams now but even after I include ifstream, fstream or anything else to try, the compiler still doesn't know what ifstream is even though I can hover the cursor over it and then start to use it and VS brings up that little class object list as I type.
Here's where I actually use the function. At this time I am only spitting the data back into another file for debug purposes but I'll eventually put the data into a CByteArray and then transmit it.
FILE * outFP = fopen("debug.dat", "w");<br />
for (int i=0; i<PacketSize; i++) {<br />
byte = BitmapFileReader->GetNextByte();<br />
fprintf(outFP, "%c", byte);<br />
}
PacketSize will almost always be 64. That for loop is inside a larger loop to keep going until it's created every packet. It's real simple, I can change functions to read the data, but I still get the same irregularities.
|
|
|
|
|
hmmm.....i dunno if thiz will help.....tis JUST a guezz.....
u see when the command that u have given
bmpFP = fopen((LPCTSTR)fileName, "r");
FILE * outFP = fopen("debug.dat", "w");
both of openz in the text mode.....u have to specfy as.....
bmpFP = fopen((LPCTSTR)fileName, "rb");
FILE * outFP = fopen("debug.dat", "wb");
becoz when it openz in text mode certain characters are not accepted by the fopen(read the documentation relating that)for example i had done thiz encrypting code on a file,when opened in text mode and when ever it encounters the 26(ascii) value it(foperationz exit like as though end of file has reached!) stopz!basically i didnt know why....but then after a long search just by putting a "b" solved my prob!
ps:i dunno if thiz will help(might sound real stupid though,but could be the cause!)even i read filez using the basic file operationz.....itz fun though it can get hectic at timez.....
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
You're now my new best friend.
I was looking into ifstream as a replacement to file pointers and ran across an option to change to a binary mode which is what I wanted but I never got it to fly. However, you pointed out that I can do that within file pointers which is mindlessly easy and simple fix. Although the file pointer irregularities are still puzzling why it did what it did, it now doesn't do that anymore with the binary mode used. You made my day, thanks a lot.
|
|
|
|
|
I think in the 'old days' a ^Z character used to signify the end of text in a text file, even if the file size was larger than that. So, when you had opened your file in 'text' mode, it read until it reached a ^Z (26) character.
|
|
|
|
|
.....glad to be of help!well yes like mr blake has said the ascii value 26 standz for end of file for a text file.....
it is there in the documentation of fopen(hmm.....i dont remeber where exactly i read it,i guess i read that from the turbo c++ version 3....they mention that in the note....yez!in turbo c++ doucumantation)!
God Bless.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
hi,
can any body tell me how to write code for programmin a serial port to communicate at low baud rates as we all know that
MS WINDOWS has API supporting upto 110 bauds ... nad we cannot use regular API to get speeds below 110 baud...
wat is the soln ...???
a sample code would b very useful
tx..!!
attitude is everything ... !!
|
|
|
|
|
I am trying to save the status of my toolbars in
the OnDestroy() funtion and restore it later.
I used first the toolbar SaveBarState("MyToolBar") but it didnt work
the way I was explained to.
Now I am trying to use a CToolBarCtrl object.
I made this call which made my app crash on destroy:
m_wndColorBar.GetToolBarCtrl().SaveState(HKEY_CURRENT_USER, "CustomApp", "ToolBarPos");
how to do it?
Thanks,
Odie
|
|
|
|
|
|
Thank you.
But I got one more questions that I could not figure out yet:
Do I have to have a SaveBarState funcion for each menu?
the online help tells me:
"Name of a section in the initialization file or a key in the Windows registry where state information is stored."
which name do I use as the argument to link to the right toolbar?
|
|
|
|
|
I think I've seen a SDK function that does this : adding a file path to the Windows/Explorer recently opened documents list.
At the beginning I thought I would find the answer quickly - it was in the morning - please, can someone give me the name of that function ?
Thanks,
Yarp
http://www.senosoft.com/
|
|
|
|
|
Have a look at SHAddToRecentDocs[^]
Gary Kirkham
Forever Forgiven and Alive in the Spirit
He is no fool who gives what he cannot keep to gain what he cannot lose. - Jim Elliot
Me blog, You read
|
|
|
|
|
I'm a complete idiot. I scaned the internet, the Add*, Update* Set* SDK functions and forgot to check the SH* ones.
Thanks a lot for the info,
Yarp
http://www.senosoft.com/
|
|
|
|
|
Hello,
Take a look at this[^]. It works fine for me.
But note when you use the code in the article that you do not need to override the CWinApp::OpenDocumentFile() function. I didn't and it still works. In technical note 22[^] it is said that it's better to leave that function alone.
Hope that this is what you are looking for.
I also got the blogging virus..[^]
|
|
|
|
|
Hi Bob,
I was looking for how to add a file to the Windows MRU. This is done with the SHAddToRecentDocs function as Gary told me - I did it this morning in my app and it works fine.
In my software I handled the MRU manually, since I also wanted to use the list for other purpose.
Thanks anyway.
Yarp
http://www.senosoft.com/
|
|
|
|
|
hi
I'm a student I developed a simple directx plug-in using vc++ 6.
it works fine but when I build the setUp prog using installShield ( the version included with vc++ 6 ) no directx application can recognize my dllplug-in.
this can be done manually after the installation using this command line:
Start -> Run -> regsvr32 ‘my_plug-in path’
how can I include this in my setUp prog so end-user does not have to do this manually?
thanx
Dennis
|
|
|
|
|
Hi,
I'd like to know if anyboby have implemented a project in C++ with mapi to navigate a outlook pst file that contains local folder's email.
Best regards
Lisa
|
|
|
|
|
How can set the printer resolution in my VC++ program without getting user input?
I don't want to use the windows defined dialog that allows the user to pick the resolution. The printer needs to constantly be set to 300 X 300 dpi. This is required to print reports. However, my program prints detailed line graphs and I need to change the resolution to 600 X 600 dpi only when printing my data.
I use:
CPrintDialog dlg(FALSE);
DEVMODE *settings;
//Get Printer diagnostics
if(!dlg.GetDefaults())
{
AfxMessageBox("dlg.GetDefaults() has failed");
}
//Sets printer resolution to 600 DPI
settings = dlg.GetDevMode();
settings->dmPrintQuality = 600;
But this has no affect. Am I missing something, or doing this completly wrong?
Thanks in advance
|
|
|
|
|
bk5151 wrote:
//Sets printer resolution to 600 DPI
settings = dlg.GetDevMode();
settings->dmPrintQuality = 600;
You need to call
ResetDC(PrinterDC,settings);//afterwards
where PrinterDC is printer device context obtained by call to dlg.GetPrinterDC() .
|
|
|
|
|
Thank you, I will try this out.
|
|
|
|
|
I tried this and it did not work. Outside of the print resolution all of my other print features work. So, I don't think that I have it set up wrong. Thank you for your help liquid
|
|
|
|
|
I am writing one application using DirectX in MSVC Visual studio6.0 if i have build my application and Run it using F5 and CtrlF5 the behaviours are different.
When i run my appllication in CtrlF5 mode it crashes (Access Violation)but this problem does not come when i run the same application using F5.
Any help will be appreciated.
Anil Kumar
|
|
|
|
|
when running in Debug Mode ( F5 ), most pointers ( AFAIK ) will be automatically initialized to NULL ( zero); and I also think that normal variables will also be initialized to some default values ( mostly 0 ).
make sure that you initialize every variables to some good default values.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi MAximilien,
So you mean to say that if Application is run ising CtrlF5 then some variables does take garbage value and may be the possibility of the crash.
Anyway thanks for the reply i will verify in my code all the pointers and variables to initialize NULL and 0s.
thanks
Anil Kumar
|
|
|
|