If I copy a region from Photoshop in RGB 8 bits the Clipboard.GetImage() has a black and white image, but if I change it to an indexed mode (256) GetImage returns a colored image.
I've also tried with the GetDataObject method, but with same results. It seems the image format is memoryBMP but in RGB/8 format so I can't get the full colored image.
How to retrieve color image from Photoshop clipboard format back into my C# app?
This is the code I'm using. The image is saved, but..
If I copy pixels from an image in Photoshop mode
RGB/8it save as b/w.If mode is
index(256 colors) it saves color.
The image format in data is of type :
[ImageFormat: b96b3caa-0728-11d3-9d7b-0000f81ef32e] MemoryBMP
Following is my C# code...
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.Dib))
{
Bitmap image = (System.Drawing.Image)data.GetData(DataFormats.Dib, false) as Bitmap;
var encoder = ImageCodecInfo.GetImageEncoders().First(c => c.FormatID == ImageFormat.Jpeg.Guid);
var encParams = new EncoderParameters(1);
encParams.Param[0] = new EncoderParameter(Encoder.ColorDepth, 24L);
image.Save("encode.jpg", encoder, encParams);
}
editbutton under your post. Or else just use link (add/editto page url) : stackoverflow.com/posts/46576473/edit