Click here to Skip to main content
Click here to Skip to main content

Pure C# MiniLZO port

, 22 Dec 2006
Rate this:
Please Sign up or sign in to vote.
Fast stream compression using a ported minilzo for .NET.


I was recently in a position where I needed to find a fast streamable compression solution.  The great source by Markus Oberhumer provided the answer. After using the C code for a while, I realized C#/.NET lacked a similar library, short of one I found which was commercial.

As a result, I decided to attempt a minimalistic port of MiniLZO compression and decompression into pure C#. At this point, the code uses unsafe/fixed blocks to best mimic the original minilzo implementation. A pure managed solution may be soon to follow (at the cost of speed).

The code has not been unit tested 100%, but all initial tests have been successful. If anyone finds any bugs, please report them so I may fix it. I also have not done any profiling of the speed yet, if anyone feels upto the task of comparing it against the C implementation.

Use of the code is relatively simple, here is a quick example.


byte[] original = File.ReadAllBytes("...");
byte[] destination;
MiniLZO.Compress(original, out destination);


byte[] destination = ...; /* Resulting buffer from above */
byte[] original = new byte[x];
MiniLZO.Decompress(destination, original);

Note that with compression, the destination buffer will be assigned and trimmed to the correct size. With decompression, the "original" buffer must be preallocated with the correct original size. Also note that my implementation removed all use of goto from the original source, and replaces certain uses with OverflowExceptions.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
Canada Canada
Short and simple, I'm a self contracted programmer, my strongest programming skills are in C/C++ and C#/.NET. I have a nack for porting C algorithms to C#.

Comments and Discussions

GeneralRe: Doesn't work on 64 bit PinmemberAstaelan4-Jan-07 19:15 
GeneralRe: Doesn't work on 64 bit Pinmembertedsmorris24-Oct-07 9:39 
GeneralRe: Doesn't work on 64 bit PinmemberAVEbrahimi17-Jun-09 22:21 
GeneralThanks PinmemberBehind The Scene22-Dec-06 13:46 
I was interested in LZO for a while. The website said that a .NET port would be arriving soon. Too bad Oberhumer's definition of "soon" was many many years (or maybe never). I'm glad you're technical skills in C brought LZO to the .NET community finally. ^_^

GeneralRe: Thanks PinmemberAstaelan23-Dec-06 4:47 
GeneralTiny bug PinmemberSimmoTech22-Nov-06 20:14 
GeneralRe: Tiny bug PinmemberAstaelan22-Dec-06 10:19 
GeneralSuggestion PinmemberOskar Austegard9-Nov-06 4:04 
GeneralRe: Suggestion PinmemberAstaelan13-Nov-06 23:54 
GeneralAnother such library... Pinmemberomaurice6-Nov-06 16:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150327.1 | Last Updated 22 Dec 2006
Article Copyright 2006 by Astaelan
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid