Issues occur when encode 4bit bmp images

Jan 27, 2015 at 10:26 AM
Hi,jdv:

My input bmp is duotu_720x1280_16se.bmp. widthxheight = 720x1280 bitdepth = 4bit . the size of bmp file is 54 + 2^44 + 720x12804/8 = 460918byte. Then I use CharLs_source code 1.0 to encode my input bmp file.I call like below:

TestFile("test/duotu_720x1280_16se.bmp", 118, Size(720,1280), 4, 1);
it shows that offset = 118 = 54 + 16x4 . cbit = 4 ccomp = 1 (Is it wright or wrong ? I think it's wright)

But when charLs run into util.cpp line 190 inside TestFile function like this:
int byteCount = size2.cx * size2.cy * ccomp * ((cbit + 7)/8);
it calculate byteCount = 720x1280x1x(4+7)/8 = 921600 not 720x1280x4/8 = 460800 .
Then issue occur ,When charLs run after ReadFile function ,it return. CharLs quit. like below:
if (!ReadFile(strName, &rgbyteUncompressed, ioffs, byteCount))
return;

if my input bmp file is 24bit bmp , cbit = 8 ccomp = 3. CharLs run successfully . The same as
my input bmp file is 8bit bmp. cbit = 8 ,ccomp = 1. So why charLs failed to encode 4bit bmp file ?

Now I want to encode different color depths such as 2bit 4bit 8bit 16bit 24bit . How to slove my problem? Thanks!
Developer
Jan 27, 2015 at 7:51 PM
Hi Steve,

I suggest to use the use the latest source code from the download page. That will make it easier to reproduce the issue (if there is one)

Victor
Jan 27, 2015 at 11:17 PM
vbaderks wrote:
Hi Steve,

I suggest to use the use the latest source code from the download page. That will make it easier to reproduce the issue (if there is one)

Victor
I don't understand what you mean. I think the code I use is just the latest source code from home page like below :

CharLS 1.0
Rating: Based on 2 ratings
Reviewed: 1 review
Downloads: 4247
Change Set: 56959
Released: Nov 9, 2010
Updated: Nov 10, 2010 by jdv
Dev status: Stable Help Icon
Developer
Jan 28, 2015 at 7:09 PM
The latest code can be downloaded from the "SOURCE CODE" page. That page will give you direct access to the GIT repository of CharLS. You can clone it or download the latest snapshot in a zip file.
Jan 29, 2015 at 2:35 AM
vbaderks wrote:
The latest code can be downloaded from the "SOURCE CODE" page. That page will give you direct access to the GIT repository of CharLS. You can clone it or download the latest snapshot in a zip file.
Hi,vbaderks:

I download the latest source code from where you said. But I fond that code implement such as TestFile was the same with source code I download before.
So. the result was the same that program still return when I encode 4bit bmp image. The new source code I download as you suggest didn't help me anything.
My problem was still around me.
  So Dear vbaderks, Would you supply me a example who can successed to encode a 4bit bmp image (cbit = 4,ccomp=1) . I don't find any similar exmple to 
encode 4bit bmp images. Why ? How can I get that examples which can encode the color depth or bit depth under 24bit (cbit=8 ccomp=3) such as 256 colors
(cbit = 8 ,ccomp=1) and 16 colors (cbit = 4,ccomp=1) ???? Why jpegls didn't support 4bit bmp image input?

Thanks!
Feb 4, 2015 at 1:54 AM
hi,vbaderks :

What's the problem status ? I was blocked by the problem for several days Please help me and give me some advice. Thanks!