Skip to content

Newbie question on using ImageSharp #1807

Answered by tocsoft
jkowalski0058 asked this question in Q&A

You must be logged in to vote

I think you want from the code above to create a grey scale image where you have a source byte[] made up of pixel data where each byte represents a single grey scale pixel.

I believe this is just the L8 pixel format (no need for palette stuff)

So I think this can all end up as a one liner of

var greyImg = Image.LoadPixelData<L8>(imageDataBytes, width, height); // don't forget to dispose of this when your finished.

if you plan to then post process the image more and need a full color space you can then use

var rgbImage = greyImg.CloneAs<Rgba32>(); // now both greyImage and rgbImage are completely separate and both need disposing

which will create a new image expanded to the full Rgba32 col…

Replies: 5 comments 11 replies

You must be logged in to vote
5 replies
@jkowalski0058

@jkowalski0058

@jkowalski0058

@tocsoft

@jkowalski0058

Answer selected by jkowalski0058

You must be logged in to vote
2 replies
@jkowalski0058

@tocsoft

You must be logged in to vote
0 replies

You must be logged in to vote
1 reply
@jkowalski0058

You must be logged in to vote
3 replies
@jkowalski0058

@jkowalski0058

@antonfirsov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants