After applying CCITT compression on my Tiff File, it produces an image with a solid black background

后端 未结 1 1668
慢半拍i
慢半拍i 2021-01-22 13:22

Creating tiff file, with LZW compression (default):-

System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(800, 1000); 
Graphics g = Graphics.FromImage(bitma         


        
相关标签:
1条回答
  • 2021-01-22 13:56

    Edit your code as such, and you will be able to use your desired compression without the black background fill:

    System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(800, 1000); 
    Graphics g = Graphics.FromImage(bitmap);
    /* Add this */ g.FillRectangle(Brushes.White, new Rectangle(0,0, 800, 1000));
    g.DrawString("Name: " + Name.Text, outputFont, Brushes.Black, new PointF(0, 20));
    g.DrawString("Date Of Birth: " + Date_Of_Birth.Text, outputFont, Brushes.Black, new PointF(0, 40));
    g.DrawString("Address: " + Address.Text, outputFont, Brushes.Black, new PointF(0, 60));
    g.DrawString("City: " + City.Text, outputFont, Brushes.Black, new PointF(0, 80));
    g.DrawString("State: " + State.Text, outputFont, Brushes.Black, new PointF(0, 100));
    g.DrawString("Zip Code: " + Zip_Code.Text, outputFont, Brushes.Black, new PointF(0, 120));
    g.DrawString("Phone: " + Phone.Text, outputFont, Brushes.Black, new PointF(0, 140));
    g.DrawString(" ID: " + ID.Text, outputFont, Brushes.Black, new PointF(0, 160));
    fileName = saveDirectory + id + ".tif";
    bitmap.Save(fileName, ImageFormat.Tiff);
    
    0 讨论(0)
提交回复
热议问题