I have this code. the method that convert to bit depth 32 and resizing the image :
the image on the hard disk 2023_01_31_02_10.png is size 940x940 bit depth 8 when i'm editing the image in Paint changing the size to 512x512 and saving it for example to 1.png then the image 1.png size is 512x512 bit depth 32.
but when i'm doing it in my code using the method Create32bpp i'm getting other results. the saved file 2.png is size 512x512 bit depth 32 and still i'm getting other results if i'm making the changes in Paint.
public static Bitmap Create32bpp(System.Drawing.Image image, Size size)
{
Bitmap bmp = new Bitmap(size.Width, size.Height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using (Graphics gr = Graphics.FromImage(bmp))
gr.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height));
return bmp;
}
private void btnCreateEffect_Click(object sender, EventArgs e)
{
Bitmap bmp = Create32bpp(new Bitmap(@"d:\New folder\2023_01_31_02_10.png"), new Size(512, 512));
bmp.Save(@"d:\New folder\2.png");
bmp.Dispose();
}
now when i'm using Paint to do this the result image is what i wanted to be :

The image is jpg because i can't upload here bmp images types. but the result is what i wanted to be when making the changes in Paint.
but when i'm doing it with the code the result image is :

what i want to do is to get batch of images all of them are png type 940x940 size bit depth 8 and convert them to png type images size 512x512 and bit depth 32.
the method above does change the png images size and bit depth but the result is not the same as in the Paint.
in the paint when i change the size to 512x512 then save it as png it's giving me message that it will lose transparency.
but the result is fine when doing it through the code i'm getting this black image.
how can i make what i'm doing in the paint but in code ?
the image above the first one with the white background is looking the same before changing it i want to keep it with the original white background just to change the size to 512x512 and the bit depth to 32.
for some reason it's not working when using the code.