Coder Social home page Coder Social logo

bitmiracle / libjpeg.net Goto Github PK

View Code? Open in Web Editor NEW
90.0 13.0 23.0 18.15 MB

LibJpeg.Net allows you to read and create JPEG images in .NET compatible languages. It's the managed version of original libjpeg library developed by Tom Lane and the Independent JPEG Group (IJG).

Home Page: http://bitmiracle.com/libjpeg/

C# 99.89% Batchfile 0.03% VBScript 0.08%
libjpeg jpeg jpeg-images jpeg-encoder jpeg-decoder

libjpeg.net's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libjpeg.net's Issues

Cross target .NETSTANDARD2.0

Microsoft recommends cross targeting .NETStandard 1.x libraries to .NETStandard 2.0 to simplify the dependency graphs. This avoids pulling in 50+ dlls on modern runtimes. Can we get a .NETSTANDARD 2.0 target for this library?

SoftwareBitmap to

Hi,

I'm trying to convert a SoftwareBitmap into a JpegImage. SoftwareBitmap is obtainted from camera data of the HoloLens.

I was getting a error from this piece of code:

private async void Send_bytes_bitmap(SoftwareBitmap frameBitmap) {
            ... 

            WriteableBitmap wrbitmap = new WriteableBitmap(frameBitmap.PixelWidth, frameBitmap.PixelHeight);
            frameBitmap.CopyToBuffer(wrbitmap.PixelBuffer);

            NetworkStream stream = new NetworkStream(sender);

            // This line gives an error
            JpegImage q = new JpegImage(wrbitmap);  

            ...
}

Is there a better/simpler way of doing this? Would appreciate your help, sorry if its a dump question this is my first experience with c# and Microsoft APIs.

Performance.

Hi there,

I've been experimenting with this library in an effort to create an cross platform imaging library for corefx and I've hit a few issues with performance.

Encoding and decoding a 3648 x 2736 image on a 12 core Intel(R) Xeon @ 3.20 Ghz. is taking me around 5-6 seconds where doing the equivalent with System.Drawing takes ~400ms.

I found an old comment in a blog post related to performance but I haven't seen any related commits in the repo.

http://bitmiracle.com/blog/libjpeg-net-is-ready-for-download

I've had a dig around the code to see what is going on but I found it very difficult to follow due to the formatting and code inconsistency, especially in the classic folder.

Do you have any plans to improve performance or do you know of any parts within the code that might be contributing to the poor performance that I should look at?

Kindest Regards

James

The image in question.

9bd24b20-bed5-11e5-84fd-15e2a83e3eb3

Black pixels do not load correctly from CMYK JPEGs

Version: https://www.nuget.org/packages/BitMiracle.LibJpeg.NET/1.5.324

I created a PNG with 16x16 blocks of Red, Green, Blue, White, Cyan, Magenta, Yellow, Black:
Colours

Then converted it to a CMYK JPEG with ImageMagick:

convert test.png -colorspace cmyk test_cmyk.jpg

test_cmyk

I then used the following code to convert it to a bitmap with BitMiracle LibJpeg.Net:

using (var bitmapStream = File.Create("test.bmp"))
using (var jpegStream = File.OpenRead("test_cmyk.jpg"))
using (var jpeg = new BitMiracle.LibJpeg.JpegImage(jpegStream))
{
    jpeg.WriteBitmap(bitmapStream);
}

This results in the black pixels being loaded as transparent (RGBA of 0xffffff00) rather than black (0x000000ff). I verified this with jpeg.GetRow(y).GetAt(x).GetComponent(c) where y=31, x=63, c=(0, 1, 2, 3) -> (255, 255, 255, 0). This appears white when the alpha channel is stripped, rather than black, which is how everything else displays it.

How can i read the raw data of jpeg without header to get mcu value to generator the width and height from raw data

Hi,

Could you give me example code of read mcu from raw data of jpeg without header only raw data after FFDA+12 bytes, because i have rebuild header for corrupted jpeg from sample jpeg have same chroma sampling, but i want to know decode the raw data of corupted jpeg to get width and height value from mcu to patch for the SOF of good header file, thank you!

Best regards,
Hanalog Inc

Support for chroma subsampling other than 4:2:0

I have tried compressing a raw 24 bpp image represented by an byte array,
I have tried both the JpegImage API and the low level jpeg_compress_struct structure,
I even tried changing the internal jpeg_set_colorspace_SET_COMP() values
i either get 4:2:0 chroma image or "Not implemented exception"
my input colorspace is RGB
my output colorspace is YcBcR

Cannot change jpeg_width and jpeg_height without reflection

I was working on a tool that let you losslessly merge two JPEGs together by putting one on top of the other. This can be done if they were saved with the same compression settings.

I did manage to get it working correctly, but I encountered one problem with the library when I had to save the JPEG file.

var decompress1 = new jpeg_decompress_struct();  //Create 'decompress' object
decompress1.jpeg_stdio_src(inputFileStream1);  //Load a JPEG file
decompress1.jpeg_read_header(true);  //Load the header
var compress = new jpeg_compress_struct();  //Create 'compress' object
compress.jpeg_stdio_dest(outputStream);  //Assign the output stream
decompress1.jpeg_copy_critical_parameters(compress);  //Copy the critical parameters
compress.Image_width = outputWidth;  //Set output width
compress.Image_height = outputHeight;  //Set output height
compress.jpeg_write_coefficients(outputBlocks);  //Set Output DCT blocks
compress.jpeg_finish_compress();  //Output the JPEG file

The problem happens when you call jpeg_finish_compress, it ignores the public Image_width and Image_height fields. Instead, it uses the private fields jpeg_width and jpeg_height to determine what dimensions to use for the output file.

In order to get the program to work, I needed to use reflection to write to those private members.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.