|
Hi,
Thanks for ur suggetion and I have done this conversion using a LUT for (4096 to 256) and will this produces a nice image or not?... actually first of all i read the data in byte format and look over it and it seems pretty much the same as i said the LSB bits in first byte and in the second byte the upper nibble are zeros and the lower nibble is consisting of remainin four bits. Wht i did is i read both bytes at a times and used the value of first byte to add with the calculated value by using the four lower bits of second byte like (like Bit0*256+Bit1*512+Bit2*1024+Bit3*2048) which gives me a values ranging between (0 - 4096) and then i used the LUT for getting corresponding greylevel in (0-255) range. Can u tell me whether I am right or not?... I would try to implement in ur way and let u know the results...
thanks,
Suman
|
|
|
|
|
I'd guess that you are probably right that LSB_MSB means that the first byte has the 8 LS bits and the next byte has the 4 unused bits (presumably the high nibble) and the 4 MS bits (the low nibble.)
Don't just go ahead without checking, though! Have a look at a sample data file to see if this assumption is valid - the weirdos who created this file format may have decided to left-justify the 12 bits in a 16-bit word, so the lowest-order 4 bits are a zero.
This may sound unlikely, but there are technical reasons for this alternative approach, in fact this is done on ARINC-429 avionic serial interfaces.
|
|
|
|
|
Hi Norman,
Thanks for ur suggetion and I have done this conversion using a LUT for (4096 to 256) and will this produces a nice image or not?... actually first of all i read the data in byte format and look over it and it seems pretty much the same as i said the LSB bits in first byte and in the second byte the upper nibble are zeros and the lower nibble is consisting of remainin four bits. Wht i did is i read both bytes at a times and used the value of first byte to add with the calculated value by using the four lower bits of second byte like (like Bit0*256+Bit1*512+Bit2*1024+Bit3*2048) which gives me a values ranging between (0 - 4096) and then i used the LUT for getting corresponding greylevel in (0-255) range. Can u tell me whether I am right or not?
thanks,
Suman
|
|
|
|
|
Interesting - I would not have thought of using a look-up table, but it should be slightly faster than shifting right by 4.
I assume that your look-up table looks something like this:
InValue OutValue<br />
4095 255<br />
4094 255<br />
. . . . <br />
4080 255<br />
4079 254<br />
. . . .<br />
16 1<br />
15 0<br />
. . . .<br />
0 0
Your approach should work, as you have described it. The only change I would suggest is that you don't need to treat each bit in the MS nibble individually.
I would do something like:
LSByte = getNextByteFromFile();<br />
MSByte = getNextByteFromFile();<br />
<br />
totalValue = (int)LSByte + ((int)MSByte)<<8;<br />
<br />
newValue = LookUpTable[totalValue];<br />
<br />
RGB24 = newValue + newValue<<8 + newValue<<16;
I think that this should give you a monochrome display which is really good. In my application I grab monochrome video frames from a camera at 8 bits per pixel, then I convert to RGB16, using a similar technique to above. This only leaves 5 bits per colour, and since R, G, B are the same, this means that I only end up with 32 different shades! The image which is displayed looks pretty good, although you can sometimes see the different grey levels. Your application will have 256 different shades of grey, which should give an excellent monochrome image!
|
|
|
|
|
Hi
I am programming a simple movie player with DirectShow now. Everything seems OK, the only thing I haven't been able to do is to change the movie resolution on the fly (for example, I want user to be able to specify, when the movie is running, whether they want to zoom in or zoom out, etc.) Could someone point me in the right direction on how to do this?
Thanks!
|
|
|
|
|
Hello:
I have this interesting problem...
I have to use a c-library that contains a function that is defined as follow:
int func(char * cpData);
I have been using a structure accually a nested structure as follows
struct A
{
char cString;
char cAnotherstring;
}sA;
struct B
{
int iIndex;
float fData[MAXDATA];
}sB;
struct C
{
struct A nA;
struct B nB[8];
}sStream;
I can call this structure with now problems
using func((char *) &sStream);
I wanted to use a vector for the float fData
such as the struct B is as follows:
struct B
{
int iIndex;
vector< float> fData;
} sB;
when I call the function I getting garbaged data.
I do take care of reserving the data size.
In fact I can see that the correct data is there just prior to calling
this legecy function.
Is there a way I can convert somehow to c-array which the function understand
but be able to use the advantage of the vector.
Your speedy reply wiill be vey much appreciated.
|
|
|
|
|
Hy,
Change call to this:
func((char*)&sStream.nA)
|
|
|
|
|
Sorry but the whole structure has to be sent.
|
|
|
|
|
And how you wan't use C++ class vector in C library ?
|
|
|
|
|
Hello,
The function takes a character array as an argument. Therefore, you cant pass a struct, unless you want to find out how the function accesses the memory...
A better way is to do your own data conversion prior to passing it to the function.
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
I'm sure its simple but I just can't seem to figure out how the get the number I have in a CString object into a float so I can do simple math on it.
I grab a CString from a CListBox, then use CString.MID to strip the string for some number values I want to add tax values to. Thats where I get stuck. Then the plan is to play with the float values and stick them into Static controls as CStrings again which I should be able to do with CString.Format.
I'm sure its just a silly beginer question, but I can't figure it out. Please help!
Jochum Wittebrood
|
|
|
|
|
I should also say i've tried: sscanf(CString,"%f",&float) which from what I have read on the web should be able to take CStrings but the compiler (MS Emmbedded visual C++ 3.0) tells me: cannot convert parameter 1 from 'class CString' to 'const char *'" so i've tried other ways to convert CString to LPTSTR and char[102] but i'm stuck. I can't think of what else to try. please help.
In VB all I used was something like: float = CCur (string)
I'm sure its not all the had in C++ but it seems to have me beat!
Thanks in Advance.
Jochum Wittebrood.
|
|
|
|
|
CString has a method to return the underlying char*, which you can then pass into atof. From memory, it's something like LockString, and you need to call a corresponding Unlock method when you've used the char * for whatever dastardly deed you intend. std::string has the c_str() function which does much the same thing. Sorry, it's too long since I lived in MFC land, I don't know the specific function you want. Hopefully this is enough to push you in the right direction
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I've had a look through the help docs for functions like that, but I can't find anything that I can get working. I can't find anything on LockString or c_str() maybe i'm not looking in the right places... It shouldn't be this hard should it?
Jochum
|
|
|
|
|
Jochum Wittebrood wrote:
It shouldn't be this hard should it?
WElcome to MFC....
The methods are GetBuffer and ReleaseBuffer.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
|
simple mathematic operations you say ?
look at this[^]
TOXCCT >>> GEII power
|
|
|
|
|
Use the generic C Runtime function _tstof() .
See MSDN for more info...
Hope this helps...
Mike
|
|
|
|
|
Thanks for all your help guys, but I tried all the functions that you suggested and they all require 'const char' where the CString seems to be 'unsigned short'. The compiler always gives me convertion errors...
It must be my VB background but I can't seem to get my head around this, while people must use it in code all the time. Does anyone have a small snippit of code to show me how they do it?
This is what I've got...
int ListIndex;
CString WorkingStr;
CString TempStr;
float TAG;
CListBox * List1=(CListBox *)GetDlgItem(IDC_LIST1);
ListIndex = List1->GetCurSel();
List1->GetText(ListIndex,WorkingStr);
TempStr = WorkingStr.Mid(54,8);
TAG = atof(TempStr);
So we know that last line is the problem, but what can I do to fix it?
Thanks for your help.
Jochum
|
|
|
|
|
Hello,
I know how to change the dropdown width of a combobox during runtime, but does anyone know how to change the width of the actual combobox at runtime?
Thanks,
Murrah Boswell
|
|
|
|
|
The combo box is the actual control, and the drop-down list box is a child of the combo box.
- To set the width of the list box, send a CB_SETDROPPEDWIDTH message (Win32) or call CComboBox::SetDroppedWidth (MFC).
- To set the width of the combo box control, call SetWindowPos (Win32) or CWnd::SetWindowPos (MFC).
Hope this helps you out.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks for the replay,
How do I get the CWnd handle of my ComboBox?
Murrah Boswell
|
|
|
|
|
Disregard CWnd question, I figured it out!
Thanks for your help,
Murrah Boswell
|
|
|
|
|
GetDlgItem(MY_COMBO)
TOXCCT >>> GEII power
|
|
|
|
|
Hi, I've created a linked list and in my C++ source file I'm creating objects and passing them to a linked list in a loop. I want to loop over the linked list to show that the values are actually in the list. How would I do this?
I've uploaded all the code here if you want to take a look: http://www.hostmaster-x.co.uk/c++/
Thanks in advance for any help.
Cheers,
lordmickel
|
|
|
|