|
I have unsigned char variable that store hex values for image. but when i wrote it in binary file and save as jpg, the image is invalid. how exactly the way to convert hex to image?
|
|
|
|
|
suggesting some checkpoints.
1. is the hex string including file header part for jpg format?
2. is your code of (HEX string -> BYTE) ok?
3. which writing function do you use? fwrite or fputc etc?
...
|
|
|
|
|
thank you for the reply. here are my answers:
1.i don't know about the value of file header. how do i get it?actually the hex string values i retrieved from database and assign to CString variable.
2.do you mean i have to convert hex string to BYTE?
3.i am using fwrite function which i assigned hex string values into unsigned char variable
|
|
|
|
|
Basically you need a better undestanding on fundamental C/C++ data types. For instance your point (2) doesn't make any sense.
Possibly you're retrieving binary data, representing an image from the database. In such case, you've just to make sure that:
- The database contains what is expectded (i.e. what is the format of the image inside the db (
raw data , bitmap , jpeg ,...)?). - Your function(s) correctly transfer on file the data retrived from the database (i.e. the
binary content of the file matches the one of the record in the database).
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]
|
|
|
|
|
refine below
1. (JPG format may not have file header section; i might be wrong. )
1'. check byte sequence of original, database and generated from your code.
annese wrote: 2.do you mean i have to convert hex string to BYTE?
generally so. you need convert char[2] to unsigned char
like "FF" (char[]) -> 0xff (unsigned char)
annese wrote: 3.i am using fwrite function which i assigned hex string values into unsigned char variable
good. but to say, you must fwrite array of BYTE above.
example)
char HEX[9] = "FFD8FFE1"; //original string
BYTE BIN[4] = { 0xff,0xd8,0xff,0xe1 }; // converted one
x fwrite(HEX, 1, 8, fp); // wrong!
o fwrite(BIN, 1, 4, fp); // good!
check further.
|
|
|
|
|
thanks for the very helpful info
|
|
|
|
|
I got too long hex string because it is an image file, size about 4k. If there any standard function to convert hex to binary? If not it will take some times to convert it? tq
|
|
|
|
|
What is CPU Time?
Some body tell me that this program use 10% CPU Time.
what does him mean?
and
How can I write the code for check CPU Time of my program,
what's function support this issue.
|
|
|
|
|
Max++ wrote: What is CPU Time?
Here[^] you go! This was my first hit when I searched.
Max++ wrote: How can I write the code for check CPU Time of my program,
You can use types in time.h[^] to find the execution time.
|
|
|
|
|
Max++ wrote: Some body tell me that this program use 10% CPU Time.
That means that the program was using the CPU 10% of the time it was running. So, if it ran for 10 minutes, I would have used 1 minute of CPU time.
Max++ wrote: How can I write the code for check CPU Time of my program,
Use GetProcessTimes [^]. The total CPU time your program has used is the sum of the user and kernel times. The total elapsed time is the creation time substracted from the current time. You can express the CPU time as a % by dividing the total CPU time by hte elapsed time.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I want to detect whether a language pack is available, on selecting a particular language in my MFC application.Can anyone help me to sort out this problem??
It may be done through registry keys,but i am not getting that how to do it?
Plz help me.
Thanks..........
|
|
|
|
|
Look into this registry entry:
HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language\
You are going to have to traverse through the entries and find the language code you are looking for. There should be code out on the web on how to traverse through registry entries to find a particular key.
Here you will find a list of Windows language codes:
http://www.science.co.il/Language/Locale-Codes.asp[^]
|
|
|
|
|
So what is the first windows' parent windows.
BTW, I create the first window myself, not using the framework.
BOOL CWnd::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd, UINT nID,
CCreateContext* pContext)
{
ASSERT(pParentWnd != NULL);
ASSERT((dwStyle & WS_POPUP) == 0);
return CreateEx(0, lpszClassName, lpszWindowName,
dwStyle | WS_CHILD,
rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
pParentWnd->GetSafeHwnd(), (HMENU)(UINT_PTR)nID, (LPVOID)pContext);
}
|
|
|
|
|
use CWnd::CreateEx
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
The code failed, why?
CWnd *pWnd=new CWnd;
LPCTSTR pClassName = AfxRegisterWndClass(CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW);
BOOL b = pWnd->CreateEx(0, pClassName, L"MyWnd",
WS_VISIBLE|WS_OVERLAPPEDWINDOW,
CRect(0,0,100,100), NULL, 1);
|
|
|
|
|
Hi everyone.
I want write a problem to edit binary file, but it is too slow when open big file, Can who send me one source code to me.
|
|
|
|
|
the source code is too big, the email can not open it.
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
ShiXiangYang wrote: Can who send me one source code to me.
Would you like mustard with it?
|
|
|
|
|
much pepper pls.
|
|
|
|
|
Mike, you never told us you were running a burger stall as well.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
|
Hi everyone,
I am in need of help here. I have a dll which create a text file using FILE* and CFile class ( I tried both ways). At each line of text, text are "\t" delimited and "\n" at the end of text. The dll is created in C++ Visual Studio v6. There used to be a application (writen in version 6 as well) calling this dll and it works fine. Now, the application is ported into C++ VS2005 platform and calling this dll. It crashes at the end of file. Basically, it doesn't pick up the last "\n" and it run into while loop one more time. Since the additional loop doesn't see an EOF or "\n", it crashes. Can anyone tells me what's going on?
One interesting thing is that the same file reader function is used elsewhere in the same application and it works fine. Please help. I've run out of ideas and tests.
modified on Friday, March 20, 2009 9:16 PM
|
|
|
|
|
Possibly yoou should post the relevant code.
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]
|
|
|
|
|
Everything is as usual. Here is a fragment of the code. Note that COXCsvFile class is a wrapper from Ultimate Toolbox.
COXCsvFile inFile;
CFileException fe;
int nRow=0;
//
// Open the input file
int nColumns = GetOurApp()->m_MIUtility.GetFileColumnCount(sFile, "\t");
if (!inFile.Open(sFile, CFile::modeRead, &fe))
{
return 1;//no record added
}
TRY
{
//inFile.GetColumns(4);
inFile.GetColumns(nColumns);
inFile.SetFieldDelimiter(_T('\t'));//set delimiter as tab
//
// Read the records in one at a time from the second table.
//
while (inFile.ReadLine())
{
inFile.ReadColumn(0, sSelCell);
inFile.ReadColumn(1, sNbCell);
inFile.ReadColumn(2, sRLAttempts);
inFile.ReadColumn(3, sTimeInActiveSet);
dSCellSCODE.strCell = sNbCell;
dSCellSCODE.strCI = strRowData;
m_aTempData.Add(dSCellSCODE);
nRow++;
}
inFile.Close();
}
CATCH_ALL(e)
{
inFile.Abort();
return 1;
}
END_CATCH_ALL
|
|
|
|
|
Are you sure it is ReadLine method failing (isn't, for instance ReadColumn )?
Probably your best friend is the debugger (and possibly you've to go deep into source, maybe even in the Toolbox's ones).
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]
|
|
|
|
|