Re: Windows CE BinaryCompression
- From: "<ctacke/>" <ctacke[@]opennetcf[dot]com>
- Date: Fri, 12 Jan 2007 16:44:36 -0500
WORD aligned means it falls on a WORD divisible address (address % 2 == 0).
DWORD aligned means it falls on a DWORD divisible address (address %4 == 0)
What exactly are you trying to do here anyway? I seriously doubt that you
should be using this undocumented kernel API from an app, let alone a
managed app.
--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
"Wagner Bertolini Junior" <wagnerbertolini@xxxxxxxxxxxxxxxxxx> wrote in
message news:uYcWqroNHHA.5016@xxxxxxxxxxxxxxxxxxxxxxx
Can anyone help me with this?
I found at winCe sources this function:
//------------------------------------------------------------------------------
// Compressors - bufin and bufout must be WORD aligned, lenout must be at
least as
// large as lenin, CECOMPRESS_FAILED is returned if it doesn't fit, else
compressed length
// CECOMPRESS_ALL_ZEROS returned if buffer entirely zero. If bufout is
NULL, the output
// length is computed, but the results are not stored. Lenin must be a
multiple of 2.
//------------------------------------------------------------------------------
DWORD
NKBinaryCompress(
LPBYTE bufin,
DWORD lenin,
LPBYTE bufout,
DWORD lenout
)
{
DWORD retval;
TRUSTED_API (L"NKBinaryCompress", CECOMPRESS_FAILED);
DEBUGMSG(ZONE_ENTRY, (L"NKBinaryCompress entry: %8.8lx %8.8lx %8.8lx
%8.8lx\r\n", bufin, lenin, bufout, lenout));
retval = CECompress(bufin, lenin, bufout, lenout, 1, 1024);
DEBUGMSG(ZONE_ENTRY, (L"NKBinaryCompress exit: %8.8lx\r\n", retval));
return retval;
}
But i CAN´T understand the comment, what is WORD aligned?
i'm trying to use it and i'm receving an Error.. i will post the sample
code:
//DWORD BinaryCompress(LPBYTE bufin, DWORD lenin, LPBYTE bufout, DWORD
lenout);
//DWORD BinaryDecompress(LPBYTE bufin, DWORD lenin, LPBYTE bufout, DWORD
lenout, DWORD skip);
[DllImport("coredll.dll", SetLastError=true)]
public static extern unsafe int BinaryCompress(byte* bufferIn, int lenIn,
byte* bufferOut, ref int lenOut);
[DllImport("coredll.dll", SetLastError = true)]
public static extern unsafe int BinaryDecompress(byte* bufferIn, int
lenIn, byte* bufferOut, ref int lenOut, int skip);
string fileOpen = "\\Temp\\test.bmp";
byte[] bFile;
bFile = OpenFile(fileOpen);
byte[] bufferNew = new byte[bFile.Length];
int iLen = 0;
int ret = 0;
fixed(byte* bLP = bFile)
fixed (byte* bLPNew = bufferNew)
{
ret = BinaryCompress(bLP, (int)bFile.Length, bLPNew, ref
iLen);
if (ret != 0)
{
ret = Marshal.GetLastWin32Error();
MessageBox.Show(new Win32Exception(ret).Message); //
this always return 87 / Win32Exception
}
}
if anyone wants to see the OpenFile
private static byte[] OpenFile(string fileOpen)
{
byte[] bFile;
FileStream fs = File.OpenRead(fileOpen);
bFile = new byte[fs.Length];
byte[] bAux = new byte[1024];
int bytToRead = (int)fs.Length;
int count = 0;
int idx = 0;
while (bytToRead > 0)
{
count = fs.Read(bAux, 0, bAux.Length);
idx = (int)fs.Length - bytToRead;
for (int i = 0; i < count; i++)
bFile[idx+i] = bAux[i];
bytToRead -= count;
}
fs.Close();
return bFile;
}
The file length is 307254 bytes.
Any idea??
Thanks a lot.
.
- Follow-Ups:
- Re: Windows CE BinaryCompression
- From: Wagner Bertolini Junior
- Re: Windows CE BinaryCompression
- References:
- Windows CE BinaryCompression
- From: Wagner Bertolini Junior
- Windows CE BinaryCompression
- Prev by Date: Re: Constant Value Where to find?
- Next by Date: Windows CE BinaryCompression
- Previous by thread: Windows CE BinaryCompression
- Next by thread: Re: Windows CE BinaryCompression
- Index(es):
Relevant Pages
|