You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
I am trying to write overlay text on images using Microsoft Maui Graphics and it's working but I am not able to change the text color from white to any other colors.
.Net 7 and Ubuntu 22.04 and 20.04
`void OverlayImage(string? path)
{
var resizeFactor = 0.9f;
var bitmap = SKBitmap.Decode(path);
var toBitmap = new SKBitmap((int)Math.Round(bitmap.Width * resizeFactor), (int)Math.Round(bitmap.Height * resizeFactor), bitmap.ColorType, bitmap.AlphaType);
var canvas = new SKCanvas(toBitmap);
// Draw a bitmap rescaled
canvas.SetMatrix(SKMatrix.CreateScale(resizeFactor, resizeFactor));
canvas.DrawBitmap(bitmap, 0, 0);
canvas.ResetMatrix();
float textSize = 12;
var font = SKTypeface.FromFamilyName("Arial");
var brush = new SKPaint
{
Typeface = font,
TextSize = textSize,
IsAntialias = true,
Color = SKColor.Parse("#39FF14")
};
string drawText = $"Test Text: ABCD132456";
canvas.DrawText(drawText, 10, 15, brush);
canvas.DrawText("www.nidoworld.com", 10, bitmap.Height - (bitmap.Height * 13 / 100), brush);
canvas.Flush();
var image = SKImage.FromBitmap(toBitmap);
var data = image.Encode(SKEncodedImageFormat.Jpeg, 90);
var stream = new MemoryStream();
data.SaveTo(stream);
if (_isImageSave == true)
{
string? filePath = "some path";
using FileStream file = new(filePath, FileMode.Create, FileAccess.Write);
stream.WriteTo(file);
}
var bytesString = Convert.ToBase64String(stream.ToArray());
data.Dispose();
image.Dispose();
canvas.Dispose();
brush.Dispose();
font.Dispose();
toBitmap.Dispose();
bitmap.Dispose();
stream.Dispose();
}`
The text was updated successfully, but these errors were encountered:
I am trying to write overlay text on images using Microsoft Maui Graphics and it's working but I am not able to change the text color from white to any other colors.
.Net 7 and Ubuntu 22.04 and 20.04
`void OverlayImage(string? path)
{
var resizeFactor = 0.9f;
var bitmap = SKBitmap.Decode(path);
The text was updated successfully, but these errors were encountered: