|
The image data address is stored in the image header itself. So better you read it and check. I think you are not considering color table info.
- NS -
|
|
|
|
|
I answered this before for you and you still haven't provided enough information.
If the BMP is a file, the file begins with a BITMAPFILEHEADER structure.
The bfOffBits member of this struct is the offset of the pixel bits from the
beginning of the file.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all, here's my question.
First I read a binary file, which includes large number of streams of bytes. Each stream has specific details. Using a buffer I read each stream and extract some details. Actually stream consist two parts, fixed data and a message. Fixed data length actually fixed in 24 number of bytes. Rest of the bytes include the message. What I want to do is, read the bytes which message include and print as a String(actually as a message).
Those bytes are in the buffer and I know how many bytes are there.
I work on Visual Studio .Net 2003
Can you guys help me to solve this.
Thanks
-- modified at 0:45 Wednesday 10th October, 2007 -- adding more details
Hi all....
|
|
|
|
|
Eranga Thennakoon wrote: What I want to do is, read the bytes which message include and print as a String(actually as a message).
this sentence is not clear can you just elaborate it?
|
|
|
|
|
Ok, after reading each stream I've found that number of bytes which include the message of each and every stream separately. As a example,
stream 1 - message use 4 bytes
stream 2 - message use 1500 bytes
stream 3 - message use 100 bytes
etc..
Right now all those bytes are in a buffer. What I want to do is read that bytes in the buffer and find the message there, I mean read stream 1 bytes of 4 and find the message. Then read the stream 2 bytes of 1500 and find the message and so on
I think it is clear now.
-- modified at 1:10 Wednesday 10th October, 2007
I appreciate your help all the time...
|
|
|
|
|
if you are able to read the number of bytes in the message from the stream,
i dont understand whats the problem in reading the message, since you know the size of the message.
on thing please be specific.
all the data, what you call it as a stream is available in the file?
and what is that you are referring the buffer as?
|
|
|
|
|
No, only thing is that I know the number of bytes use a message. I'm confusing how to read it, and get the message. If you want I can put my code here.
I appreciate your help all the time...
|
|
|
|
|
Maintain a counter where you are.
In a loop read till the end of the file.
Inside the loop,
read the length, using memcpy in a DWORD and update counter
use ur string class, and copy the buffer, till that length just read like string
s=string(buffer+counter,length); (assuming there is a constructor like this,which many
have)
update counter
end loop
Simple,
|
|
|
|
|
I'm not clear what's usage of a counter. If I read the message just after finding the length I think it is easy, because to find the length of each and every stream message I have to use a loop. Difficulty I come across with is some message length is higher than the buffer size I used.
What's your comment?
I appreciate your help all the time...
|
|
|
|
|
if you have posted your code to my mail id,
then i will get back to you in a couple of hours. keep in touch.
|
|
|
|
|
Eranga Thennakoon wrote: Can you guys help me to solve this.
Sure, which part are you stuck on? What code do you have so far?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Ok, here is my code. Sorry I don't use tags here, it gives a real mess to read the code correctly.
=============================================================================================================
#include <iostream>
#include <fstream>
#include <string>
using namespace std ;
ofstream filedata ;
// Packet content of initial 16 bytes
struct pac_cont
{
unsigned int des_list ;
unsigned int mem_ID ;
unsigned char dm_con ;
unsigned char ser_ID ;
unsigned short act ;
};
void dataExtract(int length, char *buffer)
{
struct pac_cont* p = (struct pac_cont*)buffer;
filedata.open( "RecordData.txt", ios::app ) ;
if(filedata.is_open())
{
filedata << "\t" << static_cast<int>(p->des_list) << "\t\t" << static_cast<int>(p->mem_ID)
<< "\t\t" << static_cast<int>(p->dm_con) << "\t\t" << static_cast<int>(p->ser_ID)
<< "\t\t" << static_cast<int>(p->act) << "\n";
filedata.close() ;
}
else
{
filedata << "Error in opening file RecordData.txt\n" ;
}
}
int main ()
{
ifstream fileopen ;
ofstream filerecord ;
char buffer[5000] ;
unsigned int tmp_len = 0 ; // Length of a stream
int count_mess = 0 ; // Count total message
int ID = 1 ; // Stream ID
// Open the file in binary format
fileopen.open ( "G00046_002_01.srf", ios_base::binary ) ;
// Record the stream length
filerecord.open ( "RecordLength.txt", ios_base::out ) ;
if((fileopen.is_open()) && (filerecord.is_open()))
{
// Headers of the RecordLength.txt file
filerecord << "Stream ID\tLength\t\tDescription\n\n" ;
// Headers of the RecordData.txt file
filedata.open ( "RecordData.txt", ios_base::out ) ;
if(filedata.is_open())
{
filedata << "Destination List\t" << "Member ID\t" << "Data/Message\t"
<< "Service ID\t" << "Activity ID\n\n" ;
filedata.close() ;
}
else
{
cout << "Error in opening file\n" ;
}
while(!fileopen.eof())
{
fileopen.read(buffer, 4); // Dummy read of 4 bytes
fileopen.read(buffer, 4) ; // Read next 4 bytes
tmp_len = *(unsigned int*)buffer ; // Integer value of previous 4 bytes
if(tmp_len <= 5000)
{
filerecord << ID << "\t\t" << tmp_len << "\t\t" << "-\n" ;
if(tmp_len > 16)
{
// Procesing initial 16 bytes
fileopen.read(buffer, 16) ;
dataExtract(16, buffer) ;
// Move the buffer pointer
fileopen.seekg((tmp_len - 16), ios_base::cur) ;
}
else
{
cout << "Stream is in wrong length\n" ;
}
}
else
{
filerecord << ID << "\t\t" << tmp_len << "\t\t" << "Large Size - More than 5000 bytes\n" ;
// Processing intial 16 bytes
fileopen.read(buffer, 16) ;
dataExtract(16, buffer) ;
// Move the buffer pointer
fileopen.seekg((tmp_len - 16), ios_base::cur) ;
}
ID++ ;
count_mess++ ;
}
cout << "Number of streams: " << ( ID - 1 ) << endl ;
cout << "Number of messages: " << ( count_mess - 1 ) << endl ;
fileopen.close() ;
filerecord.close() ;
}
else
{
cout << "Error in opening files" << endl ;
}
cin.get() ;
return 0 ;
}
============================================================================================================
I'll comment it as much as possible. First I read a binary file, and found how many stream of bytes are there. Actually length of those streams are not same.
Basically each stream contain three part, four bytes for part one, four bytes for part two and int value of that four bytes gives the next part bytes. The third part have 16 fixed bytes at the beginning of each. I've extract the data there using dataExtract() function, you can see that. Up to now it is ok.
Now I want to read the bytes in part three except first 16 bytes. There is a message, actually record from a online chat. I want to read it and write to a file. How can I do that.
Thanks.
I appreciate your help all the time...
|
|
|
|
|
What does stepping through each line of code with the debugger reveal?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: debugger reveal
Please can you explain it little more. It is really new for me.
Eranga
I appreciate your help all the time...
|
|
|
|
|
Buiild the project in Debug mode (instead of Release mode). Start it using F5. Use the F10 and F11 buttons to step over and into code respectively.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello again,
I want to make an "uninstall" shortcut in start menu where my software resides. How can i do this while creating setup file.
Hope somebody replies.
Thankz.
|
|
|
|
|
VC6.0 datagrid
I want to drag columns in my datagrid,so I respond to MouseDown and MouseUp Message,as following
void CTableView::OnMouseDownDatagrid(short Button, short Shift, long X, long Y)
{
// TODO: Add your control notification handler code here
col1=m_grid.ColContaining(X);
}
col1 is a member of CTableView.
but it doesn't work well
for example,If I press at column 5,it returns 5 instead of 4;
moreover,
if the position which I press at is in the first half part of columns 1, it returns 0,right!,but if the position is near column 2 in column 1, it returns 1, not expected value 0
I don't knew why
Cheers,
shakaqrj
|
|
|
|
|
can you just repost it with some better clarity?
so far, i have used flexgrid, datagrid should also be more or less same.
or if possible, attatch your application to my mail ID chandu004@yahoo.com
i shall see it.
|
|
|
|
|
Thank you!
I have sent you
|
|
|
|
|
I find this problem depends on resolution.
different resolusion gets different result.
Since I have sent you my application, please try!
Thank you!
|
|
|
|
|
What is the native approach for capturing video via FireWire under Windows? I found a lot of samples, which a using and reusing libraries and tools for these purposes, but I want to start from the very beginning, because I have to access additional commands, which are put into the stream of IEEE 1394 data, among the standard video description. Where can I get basics of IEEE 1394 programming under Windows with VC++?
P.S. Does anyone know any IEEE 1394 sniffer for Windows? There a re a lot of such tools for USB, but I found nothing for FireWire...
|
|
|
|
|
Hey Everyone,
I've got a short array that starts with 1 element (obviously) and it grows if it needs more elements. Untimately the array needs to grow as much as possible to suit the program.... I don't know however, how to return the size of the array.
e.g.
ShortArray[0] = 1;
ShortArray[1] = 5;
Length of the array is 2... Mean there are two elements. How do you return the length?
Thanks for your help in advance.... I appreciate all your input
Cheers,
Michael
|
|
|
|
|
Michael101 wrote: I've got a short array that starts with 1 element
How did you declare the array?
Michael101 wrote: Untimately the array needs to grow as much as possible to suit the program
This means you dynamically allocate the memory?
|
|
|
|
|
register short* PrimeNumber = 0;
That's how I declared the array.... I would change it if I need to though. Yeah I want allocate it more memory during runtime i.e it grows.
Cheers,
Michael
|
|
|
|
|
Michael101 wrote: I would change it if I need to though.
The memory can be allocated like
PrimeNumber = new short[2];// an array having length of 2 is created
So 2 is length of array. Similarly you can put the number of element you want in the array in the place of 2.
|
|
|
|