This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Bmp Comression to upload image to DLP Lightcrafter 6500 EVM

Other Parts Discussed in Thread: DLPC900

In the pattern on the fly mode, I saw with USB Sniffer, that if you upload for example the 0_Binary.bmp is compressed to about 6 kB instead of 259.262 Byte.

In my Testprogram, I tried to upload one image (based on https://e2e.ti.com/support/dlp__mems_micro-electro-mechanical_systems/f/94/t/411779

  • but it takes very long time to upload that image.

    I did not find out, how to correctly compress that image to RLE oder Enhanced RLE before.

    Can anyone please say, how to implement that or where to find a good source code for that.

    I tried to compress that 0_binary.bmp to rle, but I got a compressed bmp with 21 kB instead of 6 kB).

    Thank you in advance!
  • Hello f st,

    It sounds like you are using RLE Compression and you would like to use Enhanced RLE Compression.

    For a guide on how to set the compression to Enhanced RLE Compression (or uncompressed, or RLE), check out the DLPC900 Programmer's Guide Appendix C.1 "Image Header." You have to set the compression byte to 2 to enable Enhanced RLE Compression. Let me know if this helps!

    Best regards,

    Trevor

  • Hello Trevor, thank you for your reply.

    I saw that already before. Is there any existing source Code for that compression, I think, implementing that myself may take much to much
    time. It would be great, if you can post that piece of code for the Enhanced RLE compression of bmp files from the GUI "DLP LightCrafter 6500 & 9000 - 1.0.0" (The Gui for the EVM").

    To clarify once more: I want to use the same compression as in that Evaluaton program, when I load for example in pattern on the fly the 0_binary.bmp.
  • Hi f st,

    Unfortunately, the source code for the GUI (including the compression code) has not been released for the LightCrafter 6500.

    However you can still use the compression. If you follow Section 4.2.4 of the DLPC900 Programmer's Guide on sending pattern on the fly commands, it will walk you through how to send images (and it will reference Appendix C on how to set the compression byte, as I noted above). I am not sure I understand your concerns or desire for the source code, if you can elaborate a little, I might be able to help you work around them for your application.

    I hope this helps!
    Best regards,
    Trevor
  • Hello Trevor,


    sorry for my english, but I try to explain again.


    I want (for testing purposes) transfer with a command line program one image. I used that https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/94/hidtest_5F00_with_5F00_response_5F00_bit.cpp sample. The transmission is very, very slow and takes about 30 seconds or more.

    (and also I do not understand, how to convert the 0_Binary.bmp into 0_Binary.bin).


    On the Evaluation GUI, the 0_Binary.bmp is transmitted very fast (because it is compressed). So I want to find out, how to convert the uncompressed bmp to compressed to speed up the transmission in my console program.

    But I do not understnad the docs in Appendix C Pattern Image Compression. Is in the Evaluation Applicaton RLE or Enhanced RLE used?

    Why is in the Example Number 0x1234 encoded as 0xB4, 0x24  (the first hex Byte 0x12 shift >> 7 to 0x24(?), ok, 0x34 &0x/f | 0x80 to 0xB4.

    But when I see in the example:

    82 01 789ABC, how is the result (513 times) created?

  • Hi f st,

    I am not sure if you have solved this yet or not. I have similar questions regarding the programmer's guide and here's what I did.

    I ignored what happened in the example (82 01 789ABC) and just followed the control bytes table. I think it is not the most optimum way but I simply prioritized "copy from previous line" over "repeating". And with my program written in Matlab (which is far from optimized and probably has some bugs), the 0_Binary.bmp can be compressed to 8 KB and takes 0.15s to transfer.


    Here's the program:

    clc;close all;clear
    
    fileID = fopen('rgb.bmp'); 
    A = fread(fileID);
    fclose(fileID);
    
    B = A(end-1920*1080*3+1:end); % Suppose rgb.bmp is 24-bit
    
    w = 1920;
    h = 1080;
    
    Bcomp = [];
    count = zeros(h,1);
    
    % First Line
    n = 1;
    ptr = 1;
    repeat = 1;
    Bline = B((n-1)*w*3+1:n*w*3);
    while ptr <= length(Bline)-3
        % Max n = 256*256/2-1 = 32767
        if repeat == 256*256/2
            rep1 = bitor(bitand(repeat-1,hex2dec('7f')),hex2dec('80'));
            rep2 = bitshift(repeat-1,-7);
            Bcomp = [Bcomp;rep1;rep2;rgb];
            count(n) = count(n) + repeat - 1;
            repeat = 1;
        end
        rgb = Bline(ptr:ptr+2);
        ptrn = ptr+3;
        rgbn = Bline(ptrn:ptrn+2);
        if isequal(rgb,rgbn)
            repeat = repeat + 1;
            ptr = ptrn;
            continue
        elseif repeat<128
            Bcomp = [Bcomp;repeat;rgb];
            count(n) = count(n) + repeat;
            repeat = 1;
            ptr = ptrn;
        else
            rep1 = bitor(bitand(repeat,hex2dec('7f')),hex2dec('80'));
            rep2 = bitshift(repeat,-7);
            Bcomp = [Bcomp;rep1;rep2;rgb];
            count(n) = count(n) + repeat;
            repeat = 1;
            ptr = ptrn;
        end
    end
    if repeat<128
        Bcomp = [Bcomp;repeat;rgbn];
    else
        rep1 = bitor(bitand(repeat,hex2dec('7f')),hex2dec('80'));
        rep2 = bitshift(repeat,-7);
        Bcomp = [Bcomp;rep1;rep2;rgbn];
    end
    count(n) = count(n) + repeat;
    Bcomp = [Bcomp;0;0];
    
    % Second till End Lines
    for n = 2:h
        Blinep = Bline;
        Bline = B((n-1)*w*3+1:n*w*3);
        
        Blp = reshape(Blinep,3,1920);
        Blc = reshape(Bline,3,1920);
        copyFlag = zeros(1920,1);
        for m = 1:1920
            copyFlag(m) = isequal(Blp(:,m),Blc(:,m));
        end
        
        idx = 1;
        copy = 0;
        repeat = 1;
        
        while idx <= 1920
            while copyFlag(idx)&&(idx<=1920)&&(copy<256*256/2-1)
                copy = copy + 1;
                idx = idx + 1;
                if idx == 1921
                    break
                end
            end
            if copy>0&&copy<128
                Bcomp = [Bcomp;0;1;copy];
                count(n) = count(n) + copy;
            elseif copy>0
                cop1 = bitor(bitand(copy,hex2dec('7f')),hex2dec('80'));
                cop2 = bitshift(copy,-7);
                Bcomp = [Bcomp;0;1;cop1;cop2];
                count(n) = count(n) + copy;
            end
            copy = 0;
            if idx == 1921
                break
            end
            if copyFlag(idx)
                continue
            end
            
            while (~copyFlag(idx))&&(idx<=1920)
                if repeat == 256*256/2
                    rep1 = bitor(bitand(repeat-1,hex2dec('7f')),hex2dec('80'));
                    rep2 = bitshift(repeat-1,-7);
                    Bcomp = [Bcomp;rep1;rep2;rgb];
                    count(n) = count(n) + repeat - 1;
                    repeat = 1;
                end
                ptr = (idx-1)*3+1;
                rgb = Bline(ptr:ptr+2);
                ptrn = ptr+3;
                rgbn = Bline(ptrn:ptrn+2);
                if isequal(rgb,rgbn)
                    repeat = repeat + 1;
                    idx = idx + 1;
                    continue
                elseif repeat<128
                    Bcomp = [Bcomp;repeat;rgb];
                    count(n) = count(n) + repeat;
                    repeat = 1;
                    idx = idx + 1;
                else
                    rep1 = bitor(bitand(repeat,hex2dec('7f')),hex2dec('80'));
                    rep2 = bitshift(repeat,-7);
                    Bcomp = [Bcomp;rep1;rep2;rgb];
                    count(n) = count(n) + repeat;
                    repeat = 1;
                    idx = idx + 1;
                end
            end
            if isequal(rgb,rgbn)
                if repeat-1<128
                    Bcomp = [Bcomp;repeat-1;rgbn];
                    count(n) = count(n) + repeat - 1;
                else
                    rep1 = bitor(bitand(repeat-1,hex2dec('7f')),hex2dec('80'));
                    rep2 = bitshift(repeat-1,-7);
                    Bcomp = [Bcomp;rep1;rep2;rgbn];
                    count(n) = count(n) + repeat - 1;
                end
            end
            repeat = 1;
        end
        
        if n ~= h
            % End of Line
            Bcomp = [Bcomp;0;0];
        else
            % End of Image
            Bcomp = [Bcomp;0;1;0];
        end
     end

    Hope it helps!

    Regards,

    Ding