111,126
社区成员
发帖
与我相关
我的任务
分享
while ( 答案 == false)
{
Console.WriteLine("Help~~请求高手帮忙指导!");
}
private void button1_Click(object sender, EventArgs e)
{
using (Bitmap bmp = new Bitmap(@"RGB.jpg"))
{
int bmpW = bmp.Width;
int bmpH = bmp.Height;
byte[] RawBuff = null ;
Bitmap tmpBmp = new Bitmap(bmp.Width, bmp.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb );
Graphics g = Graphics.FromImage(tmpBmp);
for (int y = 0; y < bmpH; y++)
{
for (int x= 0; x < bmpW; x++)
{
Color c = bmp.GetPixel(x, y);
RawBuff = RGBToCMY(c.R, c.G, c.B);
tmpBmp.SetPixel(x, y, System.Drawing.Color.FromArgb(255,RawBuff[0], RawBuff[1], RawBuff[2]));
}
}
tmpBmp.Save(@"CMYK.tif", System.Drawing.Imaging.ImageFormat.Tiff );
}
}
Stream imageStream = new FileStream(@"C:\temp\mike4.jpg", FileMode.Open, FileAccess.Read, FileShare.Read);
BitmapSource myBitmapSource = BitmapFrame.Create(imageStream);
FormatConvertedBitmap newFormatedBitmapSource = new FormatConvertedBitmap();
newFormatedBitmapSource.BeginInit();
newFormatedBitmapSource.Source = myBitmapSource;
newFormatedBitmapSource.DestinationFormat = PixelFormats.Cmyk32;
newFormatedBitmapSource.EndInit();
BitmapEncoder encoder = new TiffBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(newFormatedBitmapSource));
Stream cmykStream = new FileStream(@"C:\temp\mike4_CMYK.tif",
FileMode.Create, FileAccess.Write, FileShare.Write);
encoder.Save(cmykStream);
cmykStream.Close();