NPOI border styles appear differently in macOS / iOS Preview - npoi

The following style
var style1 = (XSSFCellStyle)workbook.CreateCellStyle();
var pink = new XSSFColor(new byte[] { 228, 52, 145 });
style1.SetBorderColor(BorderSide.TOP, pink);
style1.BorderTop = BorderStyle.Medium;
Renders correctly in Excel
But not in macOS / iOS Preview
How could I make the borders appear correctly?

Finally, applying borders everywhere fixed the issue in macOS / iOS Preview. I added:
var grayColor = new XSSFColor(new byte[] { 210, 210, 223 });
style1.SetBorderColor(BorderSide.RIGHT, grayColor);
style1.BorderRight = BorderStyle.Thin;
style1.SetBorderColor(BorderSide.LEFT, grayColor);
style1.BorderLeft = BorderStyle.Thin;
style1.SetBorderColor(BorderSide.BOTTOM, grayColor);
style1.BorderBottom = BorderStyle.Thin;

Related

Render Issues with custom style in OpenLayers and Safari Browser

I have noticed rendering issues with a simple custom render function, code below.
I render the geometry and some Text. I can see the Text but not the Geometry itself, expect if I zoom in very close. Any idea what is causing this visual error? I'm using OL v7.2.2 and iPhone 13 Mini iOS 16.1.1
This code works on any other Browser on a Windows Machine, and this works also if I use a Style Object (style: new Style({fill: new Fill...
Example: https://jsfiddle.net/of6nvtbk/22/
Relevant Code:
const interactionLayer = new ol.layer.VectorImage({
source: featureSource,
zIndex: Number.MAX_SAFE_INTEGER,
style: (feature, resolution) => {
return new ol.style.Style({
renderer: (pxGeometry, state) => {
const polygon = new ol.geom.Polygon(pxGeometry);
const olContext = ol.render.toContext(state.context);
olContext.setFillStrokeStyle(
new ol.style.Fill({
color: "rgba(255,255,0, 1)",
}),
new ol.style.Stroke({
color: "#000",
}),
);
olContext.drawGeometry(polygon);
},
});
},
});
Iphone Screenshots while zooming in:
Edit:
Works without using drawGeometry:
ctx.beginPath();
ctx.moveTo(pxGeometry[0][0][0], pxGeometry[0][0][1]);
for (let i = 1; i < pxGeometry[0].length; i++) {
ctx.lineTo(pxGeometry[0][i][0], pxGeometry[0][i][1]);
}
ctx.closePath();
ctx.fill();

How to merge two image in Xamarin Forms?

I'm developing a Xamarin Forms iOS app. In the xaml file, there is a grid.
<Grid x:Name="QrCodeSite" HeightRequest="300" Margin="37, 37, 37, 0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
</Grid>
In the related .cs file, I use ZXing.Net.Mobile.Forms to generate a QR code and place it in the grid. And I put my logo in the same grid, which will finally appear at the center of the QR code.
var barcode = new ZXingBarcodeImageView
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
barcode.BarcodeFormat = ZXing.BarcodeFormat.QR_CODE;
barcode.BarcodeOptions.Width = 650;
barcode.BarcodeOptions.Height = 650;
barcode.BarcodeOptions.Margin = 1;
barcode.BarcodeValue = value;
var img = new Image
{
Source = "logo.png",
WidthRequest = 70,
HeightRequest = 70,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center
};
QrCodeSite.Children.Clear();
QrCodeSite.Children.Add(barcode);
QrCodeSite.Children.Add(img);
The problem is, maybe my phone (iPhone 6s plus) is too slow, sometimes the logo appears first and after a lag (around 1 second) the QR code is shown. How can I merge the QR code and the logo into one image and then add it to the grid?
You can using SkiaSharp to display Image or merge images . Having a look at how to Display SkiaSharp bitmaps to download sample project to research at it.
Based on Drawing on existing bitmaps reference , you can modify it as follow :
public partial class MonkeyMoustachePage : ContentPage
{
SKBitmap monkeyBitmap;
public MonkeyMoustachePage()
{
Title = "Monkey Moustache";
monkeyBitmap = BitmapExtensions.LoadBitmapResource(GetType(),
"SkiaSharpFormsDemos.Media.MonkeyFace.png");
SKBitmap iconImage = BitmapExtensions.LoadBitmapResource(GetType(),
"SkiaSharpFormsDemos.Media.GooglePlaylogo.png");
int offset = monkeyBitmap.Width / 2 - iconImage.Width / 2;
int offsetTop = monkeyBitmap.Height / 2 - iconImage.Height / 2;
// Create canvas based on bitmap
using (SKCanvas canvas = new SKCanvas(monkeyBitmap))
{
canvas.DrawBitmap(iconImage, SKRect.Create(offset, offsetTop, iconImage.Width, iconImage.Height));
}
// Create SKCanvasView to view result
SKCanvasView canvasView = new SKCanvasView();
canvasView.PaintSurface += OnCanvasViewPaintSurface;
Content = canvasView;
//save the new image
using (MemoryStream memStream = new MemoryStream())
using (SKManagedWStream wstream = new SKManagedWStream(memStream))
{
monkeyBitmap.Encode(wstream, imageFormat, quality);
byte[] data = memStream.ToArray();
// Check the data array for content!
bool success = await DependencyService.Get<IPhotoLibrary>().SavePhotoAsync(data, folder, filename);
// Check return value for success!
}
}
void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
{
SKImageInfo info = args.Info;
SKSurface surface = args.Surface;
SKCanvas canvas = surface.Canvas;
canvas.Clear();
canvas.DrawBitmap(monkeyBitmap, info.Rect, BitmapStretch.Uniform);
}
}
Then you will see a logo icon will display in original image :
If you want to save SkiaSharp bitmaps to files , have a look at this :https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/bitmaps/saving#exploring-the-image-formats
Note: BitmapExtensions.cs file is from sample project .By the way , when adding image to project , you need to set Build ACtion of image be Embedded resource .As follow :

ZXingBarcodeImageView (QR code) showing on iOS but not on Android (Xamarin.Forms)

This piece of code for showing a QR code in a Xamarin.Forms app works in iOS but not on Android:
let barCode = ZXingBarcodeImageView(HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
BarcodeFormat = ZXing.BarcodeFormat.QR_CODE,
BarcodeValue = foo)
barCode.BarcodeOptions.Width <- 500
barCode.BarcodeOptions.Height <- 500
mainLayout.Children.Add(barCode)
There's no error in the log, no exception thrown. Tried many heights and widths and different LayoutOptions to no avail. How can I debug this?
Luckily, I just had to play around with ZXing.Net.Mobile in my own Xamarin.Forms project. Where I managed to display the QRCode for both iOS and Android with the next C# code:
ZXingBarcodeImageView GenerateQR(string codeValue)
{
var qrCode = new ZXingBarcodeImageView
{
BarcodeFormat = BarcodeFormat.QR_CODE,
BarcodeOptions = new QrCodeEncodingOptions
{
Height = 350,
Width = 350
},
BarcodeValue = codeValue,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand
};
// Workaround for iOS
qrCode.WidthRequest = 350;
qrCode.HeightRequest = 350;
return qrCode;
}
Please note that there is a know issue in this library, and you have to set explicitly the WidthRequest & HeightRequest.
P.S.: More or less the same issue have been discussed here as well.

Display Button With Text & Image In Xamarin IOS

I want to design a custom button in Xamarin IOS to display both Text and Image.
Please find the below image.
You can find the Text and down arrow symbol in the above image.
the down arrow symbol should always display after the text. The button text is dynamic.
Can any one suggest me to solve this.
You want to use the TitleEdgeInsets & ImageEdgeInsets properties of the UIButton to control where the inset of the text and image begins:
button.TitleEdgeInsets = new UIEdgeInsets(0, -button.ImageView.Frame.Size.Width, 0, button.ImageView.Frame.Size.Width);
button.ImageEdgeInsets = new UIEdgeInsets(0, button.TitleLabel.Frame.Size.Width, 0, -button.TitleLabel.Frame.Size.Width);
Full Example:
button = new UIButton(UIButtonType.System);
button.Frame = new CGRect(150, 20, 200, 50);
button.Layer.CornerRadius = 5;
button.BackgroundColor = UIColor.Black;
button.SetTitleColor(UIColor.White, UIControlState.Normal);
button.SetImage(UIImage.FromFile("ratingstar.png"), UIControlState.Normal);
button.SetTitle("StackOverflow", UIControlState.Normal);
button.TitleEdgeInsets = new UIEdgeInsets(0, -button.ImageView.Frame.Size.Width, 0, button.ImageView.Frame.Size.Width);
button.ImageEdgeInsets = new UIEdgeInsets(0, button.TitleLabel.Frame.Size.Width, 0, -button.TitleLabel.Frame.Size.Width);

How to remove initial background image when starting a cocos2d-html project?

Initially when a cocos2d-html5 project starts (in the web browser), there is a background image showing cocos2d.
How does one remove or change it ?
This appears just after the loading screen. I cannot find a reference to it anywhere in code.
It's created in frameworks/cocos2d-html5/cocos2d/core/scenes/CCLoaderScene.js
//image move to CCSceneFile.js
var fontSize = 24, lblHeight = -logoHeight / 2 + 100;
if(cc._loaderImage){
//loading logo
cc.loader.loadImg(cc._loaderImage, {isCrossOrigin : false }, function(err, img){
logoWidth = img.width;
logoHeight = img.height;
self._initStage(img, cc.visibleRect.center);
});
fontSize = 14;
lblHeight = -logoHeight / 2 - 10;
}
And the cocos2d logo is a base64 image store in variable cc._loaderImage.
cc._loaderImage is defined in frameworks/cocos2d-html5/Base64Images.js

Resources