C
C#2y ago
Surihia

❔ Writing a existing color palette values to a existing raw image pixels to color it

I have the color palette values stored separately in a different file away from the image raw pixels file. is there a way by which I can write in the color values from the color palette file to the image and color it ?
14 Replies
lycian
lycian2y ago
There likely is, but we're going to need more information. What technology are using, what kind of image is it, etc.
Surihia
Surihia2y ago
The image is in 144x144 dimension and is RGBA 8bit(256 colors). The image data file does not contain any header and you would have to see the image in a hex editor to see the raw image visible without the colors as a grayscale. the color palette of the image is located in a separate file and each raw byte in the image data points to a offset in the color palette file.
Now I am able to write the correct values from the palette file to the image file but now I am unable to view the image to check how it looks as there is no header without which image viewers will not be able to open it. I want to add a bmp header to this file and so how do I do that?
lycian
lycian2y ago
BitmapFrame Class (System.Windows.Media.Imaging)
Represents image data returned by a decoder and accepted by encoders.
How to: Encode a Visual to an Image File - WPF .NET Framework
Learn how to encode a Visual object into an image file using a RenderTargetBitmap and a PngBitmapEncoder.
Surihia
Surihia2y ago
I am using Dotnet Is there a function to merge two different raw image data over each other like a layer on top of one another ?
lycian
lycian2y ago
dotnet has a lot of technologies under it though. WPF is one, which supports image rendering etc (like above). If you don't want to use WPF (since it's mostly for graphical applications) https://sixlabors.com/products/imagesharp/ is also a good option. Then you can follow this example: https://stackoverflow.com/questions/50860392/how-to-combine-two-images
Six Labors : ImageSharp
A modern, fully featured, fully managed, cross-platform, 2D graphics library for.NET.
Stack Overflow
How to combine two images?
Using ImageSharp for .Net core, how can I combine 2 images side by side? e.g.: make 2 100x150px become 1 100x300px (or 200x150px)
Surihia
Surihia2y ago
is this package also installable through nuget manager ?
lycian
lycian2y ago
yes. Package name is SixLabors.ImageSharp
Surihia
Surihia2y ago
Getting this error: Severity Code Description Project File Line Suppression State Error Could not install package 'SixLabors.ImageSharp.Web 2.0.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
lycian
lycian2y ago
I'm not sure what version you're getting but net472 support should be there https://www.nuget.org/packages/SixLabors.ImageSharp#supportedframeworks-body-tab
SixLabors.ImageSharp 2.1.3
A new, fully featured, fully managed, cross-platform, 2D graphics API for .NET
Surihia
Surihia2y ago
ok this one installed this doesn't take my binary data file
lycian
lycian2y ago
what is your binary data file?
Surihia
Surihia2y ago
It contains raw image data
lycian
lycian2y ago
you can still read that, fill in an Image type, and then use it.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.