简体   繁体   中英

Mono c# TextRenderingHint.SingleBitPerPixelGridFit Windows vs. Linux

We are using mono on linux and also on windows, one project that we have is to generate bitmaps with rendered text.

Because bitmaps must be in (bit per pixel format) we must omit any antialising that we don't get any shading, that all letters a totaly B&W.

For this we use TextRenderingHint.SingleBitPerPixelGridFit which on windows produces for each pixel on a bitmap value either 0 or 255 on linux it somehow ignores this setting and we get for a pixel value from 0 to 255.

Bitmap generated in windows: with setting working

OK BITMAP : ( http://shrani.si/f/2p/Mg/9JkctiS/408b7606-b74e-46cc-a5d9-.png ) (sorry i'm not allowed to post picture :)

Bitmap generated in linux: setting somehow ignored ?!? (IT HAS SHADES which it should not have!) NOT OK BITMAP: ( http://shrani.si/f/3a/ye/1Sn9rQjM/e75ab589-2061-421b-9275-.png )

Bitmap is generated with:

        b = new Bitmap(_width, _height, PixelFormat.Format16bppRgb555);
        g = Graphics.FromImage(b);

        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
        g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
        g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;

The difference is clearly shown...

Any idea how to solve this? Is this somekind of system setting or something?

I have same problem. I don't find the way setup mono print without antialiasing. But I find the way solve task on system level. You can customize settings only for selected font and size if need. Edit existing file with antialising settings or create new. /etc/fonts/conf.d/10-antialias.conf Set antialiasing to false.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!--  Use the Antialiasing -->
  <match target="font">
    <edit name="antialias" mode="assign"><bool>false</bool></edit>
  </match>
</fontconfig>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM