QRCoder icon indicating copy to clipboard operation
QRCoder copied to clipboard

Why not use Color struct instead of byte[] in color parameters?

Open doggy8088 opened this issue 2 years ago • 0 comments

Type of issue

[ ] Bug
[x] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement

Expected Behavior

In the GetGraphic method from the QRCoder.PngByteQRCode class, the darkColorRgba and the lightColorRgba use byte[] to represent RGBA color. I expected to use Color struct. It's much easier.

// QRCoder.PngByteQRCode
public byte[] GetGraphic(int pixelsPerModule, byte[] darkColorRgba, byte[] lightColorRgba, bool drawQuietZones = true)
{
	using (PngBuilder pngBuilder = new PngBuilder())
	{
		int num = (base.QrCodeData.ModuleMatrix.Count - ((!drawQuietZones) ? 8 : 0)) * pixelsPerModule;
		pngBuilder.WriteHeader(num, num, 1, PngBuilder.ColorType.Indexed);
		pngBuilder.WritePalette(darkColorRgba, lightColorRgba);
		pngBuilder.WriteScanlines(DrawScanlines(pixelsPerModule, drawQuietZones));
		pngBuilder.WriteEnd();
		return pngBuilder.GetBytes();
	}
}

Current Behavior

The byte[] is not convenient on the usage.

Possible Solution (optional)

Provide pleomorphism that accept Color struct.

Your Environment

  • Version used: 1.4.3
  • Compiled from source or NuGet package?: NuGet
  • Payload/Encoded text: 123
  • Used payload generator: N/A
  • Used ECC-level: Q
  • Used renderer class: Default
  • Environment (.NET 3.5, .NET 4.X, .NETCore, ...): .NET 7

doggy8088 avatar Aug 29 '23 14:08 doggy8088