Unable to change text color to red in a tiff image

I am unable to change text added to an image to red if the image is tiff.

201700001234_B_6.zip (39.4 KB)

Here is my code

 try
        {

            if (File.Exists(file))
            {


        
                var testFile = newFile.Replace("jpeg", "tiff");
                var newTestfile = testFile;
                var newTiff = file.Replace("jpeg", "tiff");
                using (var image = Image.Load(newTiff))
                {
                  
                   
                    Graphics graphics = new Graphics(image);

                    float fontSize = 12;
               
                    Font font = new Font("Arial", fontSize, FontStyle.Bold);

                    StringFormat format = new StringFormat();
                    
                  
                    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Color.Black);

                    if (rectsCount == 0)
                    {
                        graphics.DrawString(text, font, brush, (float)x, (float)y, format);

                    }
                    else
                    {
                        graphics.DrawString(text, font, brush, (float)x, (float)y - 17, format);
                    }
                   

                    using (var stream = new MemoryStream())
                    {

                        image.Save(stream);

                        File.WriteAllBytes(newTestfile, stream.ToArray());

                    }



                }
            }
            else
            {
                Debug.WriteLine("File does not exist");
            }

        }
        catch (Exception e)
        {
            Serilog.Log.Error(e, $"There has been an exception {e.Message}");

        }

@smooney1234

Can you please provide the working sample code along with generated output as there are custom variables used in the code for which there is no definition given. Please also try using latest Aspose.Imaigng for .NET 20.11 on your end as well.

 public void WriteTextToTiff(string text, int x, int y, string file, string newFile)
    {
        try
        {

            if (File.Exists(file))
            {


                using (var image = Image.Load(file))
                {


                    Graphics graphics = new Graphics(image);

                    float fontSize = 12;

                    Font font = new Font("Arial", fontSize, FontStyle.Bold);

                    StringFormat format = new StringFormat();


                    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Color.Black);

                    graphics.DrawString(text, font, brush, (float)x - 3, (float)y - 14, format);

                    using (var stream = new MemoryStream())
                    {

                        image.Save(stream);

                        File.WriteAllBytes(newFile, stream.ToArray());

                    }



                }
            }
            else
            {
                Debug.WriteLine("File does not exist");
            }

        }
        catch (Exception e)
        {
            Serilog.Log.Error(e, $"There has been an exception {e.Message}");

        }

    }

@smooney1234

As requested earlier please provide the generated output and also desired output.

You are setting brush colour to black rather read. Can you please also check it.

I did provide the code sample and the generated output, i cannot provide the desired output as it does not work. But the desired out is red text on tiff image. I did change the color to red, it does not work

@smooney1234

I have created an issue with ID IMAGINGNET-4280 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@smooney1234

We have observed the file that you have shared. It is in black/white mode, so to draw in Color mode it should be resaved in another Color mode. Then you can try the shared code and I hope it will work.

how do i do that?

@smooney1234

Actually, the file is a 1 bit uncompressed tiff. It does not support any other colors than black and white.