Оптимизация. Добавлен _memcmp

This commit is contained in:
freebipman 2020-08-16 20:05:25 +10:00
parent ad003776ae
commit 218c15c2d9
4 changed files with 20 additions and 12 deletions

View File

@ -49,8 +49,8 @@ namespace BipEmulator.Host
if (_paletteColors > 0)
ReadPalette(br);
else if (_bitsPerPixel == 8 || _bitsPerPixel == 16 || _bitsPerPixel == 24 || _bitsPerPixel == 32)
Debug.WriteLine("The image doesn't use a palette.");
//else if (_bitsPerPixel == 8 || _bitsPerPixel == 16 || _bitsPerPixel == 24 || _bitsPerPixel == 32)
// Debug.WriteLine("The image doesn't use a palette.");
else
throw new ArgumentException(
"The image format is not supported. Please report the issue on https://bitbucket.org/valeronm/amazfitbiptools");
@ -60,21 +60,21 @@ namespace BipEmulator.Host
private void ReadHeader(BinaryReader br)
{
Debug.WriteLine("Reading image header...");
//Debug.WriteLine("Reading image header...");
_width = br.ReadUInt16();
_height = br.ReadUInt16();
_rowLengthInBytes = br.ReadUInt16();
_bitsPerPixel = br.ReadUInt16();
_paletteColors = br.ReadUInt16();
_transparency = br.ReadUInt16() > 0;
Debug.WriteLine("Image header was read:");
Debug.WriteLine("Width: {0}, Height: {1}, RowLength: {2}", _width, _height, _rowLengthInBytes);
Debug.WriteLine("BPP: {0}, PaletteColors: {1}, Transaparency: {2}", _bitsPerPixel, _paletteColors, _transparency);
//Debug.WriteLine("Image header was read:");
//Debug.WriteLine("Width: {0}, Height: {1}, RowLength: {2}", _width, _height, _rowLengthInBytes);
//Debug.WriteLine("BPP: {0}, PaletteColors: {1}, Transaparency: {2}", _bitsPerPixel, _paletteColors, _transparency);
}
private void ReadPalette(BinaryReader br)
{
Debug.WriteLine("Reading palette...");
//Debug.WriteLine("Reading palette...");
_palette = new Color[_paletteColors];
for (var i = 0; i < _paletteColors; i++)
{
@ -86,10 +86,10 @@ namespace BipEmulator.Host
if (padding != 0) Debug.WriteLine("Palette item {0} last byte is not zero: {1:X2}", i, padding);
var isColorValid = (r == 0 || r == 0xff) && (g == 0 || g == 0xff) && (b == 0 || b == 0xff);
if (isColorValid)
Debug.WriteLine("Palette item {0}: R {1:X2}, G {2:X2}, B {3:X2}", i, r, g, b);
else
Debug.WriteLine("Palette item {0}: R {1:X2}, G {2:X2}, B {3:X2}, color isn't supported!", i, r, g, b);
//if (isColorValid)
// Debug.WriteLine("Palette item {0}: R {1:X2}, G {2:X2}, B {3:X2}", i, r, g, b);
//else
// Debug.WriteLine("Palette item {0}: R {1:X2}, G {2:X2}, B {3:X2}, color isn't supported!", i, r, g, b);
var alpha = _transparency && i == 0 ? 0x00 : 0xff;
_palette[i] = Color.FromArgb(alpha, r, g, b);

View File

@ -144,6 +144,7 @@ namespace BipEmulator.Host
private Color GetRealColor(Color color)
{
//return color;
switch ((uint)color.ToArgb())
{
// red

View File

@ -445,6 +445,12 @@ int _memset(void* buf, int len, int val)
return (int)memset(buf, val, len);
}
int _memcmp(const void* p1, const void* p2, int size)
{
return (int)memcmp(p1, p2, size);
}
int show_watchface()
{
return 0;

View File

@ -215,7 +215,8 @@ int _memclr(void* buf, int len);
int _memcpy(void* dest, const void* srcptr, int num);
// âñòðîåííàÿ â ïðîøèâêó ôóíêöèÿ memset
int _memset(void* buf, int len, int val);
// âñòðîåííàÿ â ïðîøèâêó ôóíêöèÿ memcmp
int _memcmp(const void* p1, const void* p2, int size);
int show_watchface();
void* get_ptr_temp_buf_2();