C # Convert indexed pixel to new bit bit32

Does anyone have a code example on how I can open a tif file, copy it to a new location from an indexed pixel in a new 32 bitmap?

I found this http://fci-h.blogspot.com/2008/02/c-indexed-pixel-problem.html But I will be new to put it together. Is there a way to just read all this in memory without actually creating a new file?

I mean it. I have to find the source file (which I already have). Copy the file to a temporary location (which I received). I donโ€™t understand how, when copying this new file, I need to keep the original size and give the new file a 32 bitmap.

I cannot draw an image above the frame because C # really does not support indexed pixels.

+3
source share
2 answers

It does what you want, I think ...

If you do not need to save it, just work with "bm" after creating DrawImage, that is, your image as a bitmap ...

            Bitmap bm = (Bitmap)System.Drawing.Image.FromFile("TifFilePath.tif", true);
            Bitmap tmp = new Bitmap(bm.Width, bm.Height);
            Graphics grPhoto = Graphics.FromImage(tmp);
            grPhoto.DrawImage(bm, new Rectangle(0, 0, tmp.Width, tmp.Height), 0, 0, tmp.Width, tmp.Height, GraphicsUnit.Pixel);
            bm.Save("JPGFilePath.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            grPhoto.Dispose();
+2
source
Bitmap newImage = new Bitmap(original);

This will cause your newImage to begin with the contents of the original. The difference will be that in the end you get newImage.PixelFormat == PixelFormat.Format32bppArgb, regardless of the original. PixelFormat

+2
source

Source: https://habr.com/ru/post/1728349/


All Articles