473,804 Members | 3,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using c libraries: zlib.lib, libjpeg.lib

Hello,
I am pretty new to .NET programming and probably my question has an obvious
answer:

I am starting to port an existing c++ application to c#.NET
The first problem i am facing is that the app uses two open-source "c"
compression libraries:
zlib.lib and libjpeg.lib.

I would really want ot avoid rewriting those libraries, because it's a huge
amount of code, so is there any way to use the lib's or recompile the source
code some special way?

Any suggestions would be highly appreciated!

Thank you,
Andrey
Nov 15 '05 #1
1 6768

"MuZZy" <le*******@yaho o.com> wrote in message
news:xTs_b.1101 79$uV3.597125@a ttbi_s51...
Hello,
I am pretty new to .NET programming and probably my question has an obvious answer:

I am starting to port an existing c++ application to c#.NET
The first problem i am facing is that the app uses two open-source "c"
compression libraries:
zlib.lib and libjpeg.lib.

I would really want ot avoid rewriting those libraries, because it's a huge amount of code, so is there any way to use the lib's or recompile the source code some special way?

Any suggestions would be highly appreciated!

Thank you,
Andrey


The easiest way is to create a managed C++ assembly that provides class
wrappers for the C routines. You can then use this assembly(s) from C#.

[Warning aircode follows...]
extern "C" {
#include <stdio.h>
#include <zlib.h> // assume there is one
#include <jpep.h>
}
#using <mcorlib.dll>
using namespace System::Runtime ::InteroptServi ces;
using namespace System;
namespace Zlib {
[DllImport("zlib ")]
extern "C" void SomeZlibFunctio n();
...
public __gc class ZlibFunctions
{
void MyNewCall() {
SomeZlibFunctio n();
}
...
}
};

In your C# code just add
using ZLIB;
You can now use the c libs just like they were another assembly. You can
also inherit from the classes.

HTH
-ralph
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3752
by: Alan Toppen | last post by:
I was unable to use the ZipFile class in the zipfile module in Python2.4. I got an error that zlib could not be found. Comparing my Python 2.2 installation I noticed Python 2.4 was missing a certain file: /usr/lib/python2.2/lib-dynload/zlibmodule.so. Unable to find a more elegant solution, I copied the file from my Python 2.2 directory into my Python 2.4 directory. When running my Python script it gives a warning: ...
0
3528
by: Tony | last post by:
Hello, Any assistance would be appreciated: As the subject suggests I am trying to gunzip files using the Compress::Zlib module. The following is basically the code that I am working with: ------------------------------------------------ ------------------------------------------------
0
2026
by: Richard Taylor | last post by:
User-Agent: OSXnews 2.07 Xref: number1.nntp.dca.giganews.com comp.lang.python:437315 Hi I am trying to use py2app (http://undefined.org/python/) to package a gnome-python application called gramps (http://www.gramps-project.org) for MAC OS X.
1
7945
by: Dennis Powell | last post by:
Does anyone have a successful implementaion of the zlib.dll in VB. Net they can show me. I'm writting a class encaplsulating zlib functionality and I keep getting a System.NullReferenceException (Object reference not set to an instance of an object) when I try to call the dll's compress function. The function in the dll is declared as such: int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) I've...
1
2473
by: Leif Wessman | last post by:
I enabled automatic gzip compression with the following lines in ..htaccess: php_value zlib.output_compression On php_value zlib.output_compression_level 5 The problem is that the Content-Encoding header does not get set at all in the response. Therefore, a browser that advertises itself as supporting gzip compression (Accept-Encoding: gzip,deflate) receives compressed content but does not know it is compressed.
0
1386
by: mikko.koivunen | last post by:
Hello all, I am installing the Python Imaging Library (1.1.5). Following the README that came with PIL sources, I ran "path/to/python setup.py build_ext -i" which informed me that JPEG support is OK. However when I run "path/to/python selftest.py" from the same package, I get an IOError: decoder jpg not available. This is a RHEL4 server and I am building PIL for a selfcompiled Python
3
5447
by: beantant | last post by:
hi, i have been trying to get libjpeg working with gd & php on centos. php is compiled from source (with gd option) and when i try compiling libjpeg this happens: # ./configure --prefix=/usr --enable-shared ..... ..... -no errors
5
4816
by: tombrogan3 | last post by:
Hi, I need to implement in-memory zlib compression in c# to replace an old c++ app. Pre-requisites.. 1) The performance must be FAST (with source memory sizes from a few k to a meg). 2) The output must match exactly compression generated with the c++ zlib.org code with default compression. zlib.org c# code is as slow as hell! Not sure if I'm doing anything
4
2346
by: stuntgoat | last post by:
Hi, I want to start using Python 2.6 and 3000. I have several questions. What, in your experiences, is a functionally elegant solution to installing 2.6 and 3 from source without breaking package dependencies on your favorite Linux/Unix flavor? Is compiling Python 2.6 and 3.0 on a *nix development machine and having it work seamlessly as simple as choosing a particular flavor or are there always going to be package...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9577
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10569
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.