C# Bitmap zu byte[] für Arduino GFX

  • C

Es gibt 21 Antworten in diesem Thema. Der letzte Beitrag () ist von Nofear23m.

    C# Bitmap zu byte[] für Arduino GFX

    Hallo Leute

    Evtl. ist ja jemand dabei der mir Helfen kann.

    Ich möchte ein Display ansteuern mittels ESP32 und versuche es hinzubekommen das meine API ein monochromes Bild als ByteArray zurückgibt welches im richtigen Format vorliegt.

    Hinterlege ich ein Bild direkt im Quellcode funktioniert das ganze super.
    Hier gibt es einen Converter welches folgendes Bild:


    zu diesem Convertiert:


    und mir dann folgendes Array ausspuckt:

    Spoiler anzeigen
    // '3128-0124b76125128a33003a968a4d2882f1479dd93f', 128x128px
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xbf, 0x0d, 0x0c, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c,
    0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x60, 0x7b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0x7f, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x1f, 0x0f, 0xaf, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xeb, 0xe7, 0xf7, 0xf3,
    0xf7, 0xff, 0xff, 0x7f, 0x5f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x30, 0x74, 0x7f, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0x7f, 0x7f, 0x1f, 0x1f, 0x0f, 0x0e,
    0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x0f, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x1f, 0x3f, 0x1f, 0x17, 0x0f, 0x01, 0x00, 0x00,
    0x01, 0x0c, 0x7f, 0x1f, 0x1f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0e, 0x04, 0x00, 0x01,
    0x01, 0x01, 0x0b, 0x77, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0xdf, 0x5f, 0x0f,
    0x5f, 0x5f, 0x40, 0x20, 0xa0, 0x63, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf1, 0xf1, 0x3d, 0x3d, 0xf1,
    0x71, 0xb1, 0xfb, 0xff, 0x7e, 0x40, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0f, 0x2f,
    0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x0f, 0x3f, 0x1f, 0x0d, 0x1e, 0x04, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00,
    0x00, 0x00, 0x20, 0x10, 0x10, 0x00, 0x20, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x08, 0x08, 0x09, 0x08, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x1f, 0x14, 0x00, 0x00, 0x00,
    0x00, 0x85, 0xff, 0xdb, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08,
    0x80, 0x61, 0x30, 0x20, 0x60, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0xa0, 0xe0, 0xa0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x40,
    0xa0, 0xc0, 0x88, 0x48, 0xc0, 0xb8, 0xf8, 0xe0, 0xe0, 0xc0, 0xc0, 0xe0, 0x40, 0xc0, 0xc0, 0x80,
    0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0, 0xf0,
    0xe0, 0xa0, 0xf0, 0x70, 0x1c, 0x7c, 0x1f, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xe0, 0x00,
    0xe1, 0x74, 0x31, 0x19, 0x01, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x08, 0x10, 0x00, 0x20, 0x60,
    0x40, 0x40, 0x80, 0x80, 0xc0, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x80, 0x0a, 0x00, 0x01,
    0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x7f, 0x5b, 0x3d, 0x0f, 0x27, 0x0f, 0x5f, 0xaf, 0x3f, 0x7b, 0x17, 0x2f, 0x3f, 0x3f, 0x1f, 0x4f,
    0x5f, 0x8f, 0xff, 0x3f, 0x2f, 0x3e, 0x1f, 0x1f, 0x3f, 0x0e, 0x2e, 0x9e, 0x1f, 0x7f, 0xfe, 0xf2,
    0xf2, 0x7e, 0xf3, 0x73, 0xf6, 0xf5, 0xf5, 0xf3, 0x37, 0x1a, 0x07, 0x07, 0x03, 0x03, 0x07, 0x01,
    0x00, 0x11, 0x83, 0x82, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe0, 0xc0, 0x80,
    0xe1, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00,
    0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x30, 0x70, 0xf8, 0xf8, 0xd8, 0xf8, 0xdc, 0xdc, 0xdc, 0xec,
    0xcc, 0xe8, 0xc8, 0xc8, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00,
    0x84, 0x84, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
    0x0c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x01, 0x01, 0x88, 0x88, 0x00, 0x10, 0x80, 0x82, 0xc1, 0x40, 0xc0, 0x00, 0xea, 0x88, 0xc1, 0xc1,
    0x60, 0x98, 0x04, 0x04, 0x03, 0x13, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x9f, 0xcf, 0x5f, 0xdb, 0x7f, 0x47,
    0x05, 0x01, 0x87, 0x07, 0x1f, 0x3f, 0x5b, 0x5f, 0x4f, 0x77, 0x3f, 0x1b, 0x57, 0x2f, 0x11, 0x03,
    0x01, 0x07, 0x02, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x1a, 0x0e, 0x0e, 0x22, 0x02, 0x4a, 0x01,
    0x5f, 0x7f, 0xbf, 0x7e, 0x3e, 0x7f, 0x7e, 0x1e, 0x7e, 0x3e, 0xff, 0xff, 0xbf, 0x7f, 0xff, 0xff,
    0xff, 0xfb, 0xff, 0xfb, 0xf3, 0xf1, 0xf0, 0xf1, 0xf1, 0xf2, 0xe1, 0xe0, 0x91, 0x00, 0x00, 0xc0,
    0x80, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x40, 0xa0, 0xa0, 0x04, 0x8e, 0x14, 0x80, 0x20,
    0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0c, 0x00, 0x0e, 0x1c, 0x18, 0x00, 0x00, 0x00, 0x00,
    0x02, 0x00, 0x00, 0x80, 0x00, 0x21, 0x01, 0x10, 0x20, 0x30, 0x14, 0x00, 0x20, 0x00, 0x00, 0x10,
    0xf0, 0xae, 0x43, 0x52, 0xa4, 0x42, 0x00, 0x00, 0x01, 0x04, 0x18, 0x00, 0x01, 0x00, 0x10, 0x00,
    0x0b, 0x00, 0x80, 0xe5, 0x03, 0x01, 0x0f, 0x0b, 0x09, 0x01, 0x03, 0x80, 0x41, 0x03, 0x83, 0x07,
    0x0e, 0x02, 0x00, 0x09, 0x0f, 0x02, 0x90, 0xfc, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
    0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xc0, 0xd0, 0x9c, 0x90, 0x58, 0x10, 0x00, 0x63, 0x21,
    0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
    0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x40, 0x48, 0x04, 0x0c, 0x04, 0x20, 0x38, 0x36, 0x38, 0x3e, 0x37, 0x2b, 0x08, 0x00,
    0x00, 0x0e, 0x27, 0x0d, 0x0d, 0x08, 0x00, 0x00, 0x46, 0x14, 0x00, 0x00, 0x20, 0x61, 0x01, 0x0c,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xbf, 0xf0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1f,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x3f, 0x3f, 0x07,
    0x00, 0x00, 0x00, 0x00, 0x80, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
    0xbc, 0xb8, 0xb0, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x30, 0x90, 0x50, 0xa0, 0xa0, 0x60, 0x70, 0x20,
    0x00, 0x30, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x00, 0x80, 0x80, 0x80, 0x80,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x10, 0x00, 0x00, 0x80, 0x00, 0x44, 0x84, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x20, 0x18, 0x00, 0xa0, 0x80, 0x28, 0x00, 0x00, 0x13, 0x1c, 0xe2, 0xf8, 0x58, 0x00, 0x0f,
    0x0f, 0x9f, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    0xff, 0x9f, 0x1f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xf3, 0xfe, 0xfc, 0xf8,
    0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x01, 0x83, 0x43, 0x47, 0x01, 0x03, 0x0b, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x0b, 0x00, 0x83, 0x83, 0x00,
    0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x04, 0x80, 0x01, 0x05, 0x01, 0x00, 0x80, 0x00,
    0x0f, 0x0f, 0x0f, 0x0f, 0x1f, 0x3f, 0x1f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
    0x3f, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1f, 0x3f, 0x1f, 0x0f, 0x0f, 0x07, 0x03, 0x03, 0x01, 0x00,
    0xe8, 0x04, 0x00, 0x00, 0x0a, 0x08, 0x00, 0x00, 0x04, 0x08, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x20, 0x00, 0x08, 0x08, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xc0, 0xf0, 0xfc, 0xff, 0x9f,
    0x06, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x0d, 0x3e, 0xb0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x42, 0x02, 0x00, 0x00, 0x80, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x20, 0x20, 0x00, 0x38, 0x1c, 0x18, 0x0c,
    0x1c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x24, 0x07, 0xff, 0x7f, 0x0f, 0x81,
    0x0b, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
    0xd0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x10, 0x48, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,
    0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
    0x40, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0xff, 0x5d, 0x1e, 0x01,
    0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff, 0xff, 0xfc,
    0xfd, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08,
    0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xf0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff

    Das ist ein unsigned char.

    Nun meine Frage. Hat jemand Ahnung wie ich es hinbekomme das ich unter C# ein Bitmap/Image Object zu einem unsigned char Konvertiere.
    Einfach in ein byteArray zu wandeln funktioniert leider nicht. Das Bild kommt zwar an, ich empfange aber leider nur Salat am Display.

    Verwende ich einfach die Umwandlung in ein byteArray in meiner API kommt nur Salat am Display an:
    Spoiler anzeigen

    C#-Quellcode

    1. return new byte[]{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    2. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    3. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    4. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    5. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    6. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    7. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    8. 0xbf, 0x0d, 0x0c, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    9. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    10. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    11. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    12. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    13. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c,
    14. 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x60, 0x7b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    15. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    16. 0x7f, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    17. 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff,
    18. 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x1f, 0x0f, 0xaf, 0xff, 0xff, 0xff, 0xff, 0xff,
    19. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    20. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xeb, 0xe7, 0xf7, 0xf3,
    21. 0xf7, 0xff, 0xff, 0x7f, 0x5f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    22. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x30, 0x74, 0x7f, 0xff, 0xff, 0xff, 0xff,
    23. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0x7f, 0x7f, 0x1f, 0x1f, 0x0f, 0x0e,
    24. 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    25. 0x0f, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x1f, 0x3f, 0x1f, 0x17, 0x0f, 0x01, 0x00, 0x00,
    26. 0x01, 0x0c, 0x7f, 0x1f, 0x1f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0e, 0x04, 0x00, 0x01,
    27. 0x01, 0x01, 0x0b, 0x77, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0xdf, 0x5f, 0x0f,
    28. 0x5f, 0x5f, 0x40, 0x20, 0xa0, 0x63, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf1, 0xf1, 0x3d, 0x3d, 0xf1,
    29. 0x71, 0xb1, 0xfb, 0xff, 0x7e, 0x40, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    30. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0f, 0x2f,
    31. 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x0f, 0x3f, 0x1f, 0x0d, 0x1e, 0x04, 0x00, 0x00, 0x00, 0x00,
    32. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    33. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    34. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00,
    35. 0x00, 0x00, 0x20, 0x10, 0x10, 0x00, 0x20, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    36. 0x00, 0x00, 0x08, 0x08, 0x09, 0x08, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x1f, 0x14, 0x00, 0x00, 0x00,
    37. 0x00, 0x85, 0xff, 0xdb, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    38. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08,
    39. 0x80, 0x61, 0x30, 0x20, 0x60, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
    40. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    41. 0xa0, 0xe0, 0xa0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x40,
    42. 0xa0, 0xc0, 0x88, 0x48, 0xc0, 0xb8, 0xf8, 0xe0, 0xe0, 0xc0, 0xc0, 0xe0, 0x40, 0xc0, 0xc0, 0x80,
    43. 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0, 0xf0,
    44. 0xe0, 0xa0, 0xf0, 0x70, 0x1c, 0x7c, 0x1f, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xe0, 0x00,
    45. 0xe1, 0x74, 0x31, 0x19, 0x01, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x08, 0x10, 0x00, 0x20, 0x60,
    46. 0x40, 0x40, 0x80, 0x80, 0xc0, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x80, 0x0a, 0x00, 0x01,
    47. 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    48. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    49. 0x7f, 0x5b, 0x3d, 0x0f, 0x27, 0x0f, 0x5f, 0xaf, 0x3f, 0x7b, 0x17, 0x2f, 0x3f, 0x3f, 0x1f, 0x4f,
    50. 0x5f, 0x8f, 0xff, 0x3f, 0x2f, 0x3e, 0x1f, 0x1f, 0x3f, 0x0e, 0x2e, 0x9e, 0x1f, 0x7f, 0xfe, 0xf2,
    51. 0xf2, 0x7e, 0xf3, 0x73, 0xf6, 0xf5, 0xf5, 0xf3, 0x37, 0x1a, 0x07, 0x07, 0x03, 0x03, 0x07, 0x01,
    52. 0x00, 0x11, 0x83, 0x82, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe0, 0xc0, 0x80,
    53. 0xe1, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00,
    54. 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x30, 0x70, 0xf8, 0xf8, 0xd8, 0xf8, 0xdc, 0xdc, 0xdc, 0xec,
    55. 0xcc, 0xe8, 0xc8, 0xc8, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00,
    56. 0x84, 0x84, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
    57. 0x0c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    58. 0x01, 0x01, 0x88, 0x88, 0x00, 0x10, 0x80, 0x82, 0xc1, 0x40, 0xc0, 0x00, 0xea, 0x88, 0xc1, 0xc1,
    59. 0x60, 0x98, 0x04, 0x04, 0x03, 0x13, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    60. 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    61. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
    62. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x9f, 0xcf, 0x5f, 0xdb, 0x7f, 0x47,
    63. 0x05, 0x01, 0x87, 0x07, 0x1f, 0x3f, 0x5b, 0x5f, 0x4f, 0x77, 0x3f, 0x1b, 0x57, 0x2f, 0x11, 0x03,
    64. 0x01, 0x07, 0x02, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x1a, 0x0e, 0x0e, 0x22, 0x02, 0x4a, 0x01,
    65. 0x5f, 0x7f, 0xbf, 0x7e, 0x3e, 0x7f, 0x7e, 0x1e, 0x7e, 0x3e, 0xff, 0xff, 0xbf, 0x7f, 0xff, 0xff,
    66. 0xff, 0xfb, 0xff, 0xfb, 0xf3, 0xf1, 0xf0, 0xf1, 0xf1, 0xf2, 0xe1, 0xe0, 0x91, 0x00, 0x00, 0xc0,
    67. 0x80, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    68. 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    69. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    70. 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x40, 0xa0, 0xa0, 0x04, 0x8e, 0x14, 0x80, 0x20,
    71. 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0c, 0x00, 0x0e, 0x1c, 0x18, 0x00, 0x00, 0x00, 0x00,
    72. 0x02, 0x00, 0x00, 0x80, 0x00, 0x21, 0x01, 0x10, 0x20, 0x30, 0x14, 0x00, 0x20, 0x00, 0x00, 0x10,
    73. 0xf0, 0xae, 0x43, 0x52, 0xa4, 0x42, 0x00, 0x00, 0x01, 0x04, 0x18, 0x00, 0x01, 0x00, 0x10, 0x00,
    74. 0x0b, 0x00, 0x80, 0xe5, 0x03, 0x01, 0x0f, 0x0b, 0x09, 0x01, 0x03, 0x80, 0x41, 0x03, 0x83, 0x07,
    75. 0x0e, 0x02, 0x00, 0x09, 0x0f, 0x02, 0x90, 0xfc, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
    76. 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    77. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    78. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xc0, 0xd0, 0x9c, 0x90, 0x58, 0x10, 0x00, 0x63, 0x21,
    79. 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
    80. 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
    81. 0x00, 0x00, 0x40, 0x48, 0x04, 0x0c, 0x04, 0x20, 0x38, 0x36, 0x38, 0x3e, 0x37, 0x2b, 0x08, 0x00,
    82. 0x00, 0x0e, 0x27, 0x0d, 0x0d, 0x08, 0x00, 0x00, 0x46, 0x14, 0x00, 0x00, 0x20, 0x61, 0x01, 0x0c,
    83. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xbf, 0xf0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1f,
    84. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    85. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x3f, 0x3f, 0x07,
    86. 0x00, 0x00, 0x00, 0x00, 0x80, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
    87. 0xbc, 0xb8, 0xb0, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x30, 0x90, 0x50, 0xa0, 0xa0, 0x60, 0x70, 0x20,
    88. 0x00, 0x30, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x00, 0x80, 0x80, 0x80, 0x80,
    89. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
    90. 0x00, 0x10, 0x00, 0x00, 0x80, 0x00, 0x44, 0x84, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    91. 0x00, 0x20, 0x18, 0x00, 0xa0, 0x80, 0x28, 0x00, 0x00, 0x13, 0x1c, 0xe2, 0xf8, 0x58, 0x00, 0x0f,
    92. 0x0f, 0x9f, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    93. 0xff, 0x9f, 0x1f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xf3, 0xfe, 0xfc, 0xf8,
    94. 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
    95. 0x01, 0x83, 0x43, 0x47, 0x01, 0x03, 0x0b, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00,
    96. 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x0b, 0x00, 0x83, 0x83, 0x00,
    97. 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    98. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
    99. 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x04, 0x80, 0x01, 0x05, 0x01, 0x00, 0x80, 0x00,
    100. 0x0f, 0x0f, 0x0f, 0x0f, 0x1f, 0x3f, 0x1f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
    101. 0x3f, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1f, 0x3f, 0x1f, 0x0f, 0x0f, 0x07, 0x03, 0x03, 0x01, 0x00,
    102. 0xe8, 0x04, 0x00, 0x00, 0x0a, 0x08, 0x00, 0x00, 0x04, 0x08, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,
    103. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
    104. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    105. 0x00, 0x20, 0x00, 0x08, 0x08, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00,
    106. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
    107. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xc0, 0xf0, 0xfc, 0xff, 0x9f,
    108. 0x06, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    109. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    110. 0x0d, 0x3e, 0xb0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x42, 0x02, 0x00, 0x00, 0x80, 0x00,
    111. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
    112. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    113. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    114. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x20, 0x20, 0x00, 0x38, 0x1c, 0x18, 0x0c,
    115. 0x1c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x24, 0x07, 0xff, 0x7f, 0x0f, 0x81,
    116. 0x0b, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
    117. 0xd0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    118. 0x10, 0x48, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    119. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    120. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0,
    121. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,
    122. 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
    123. 0x40, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0xff, 0x5d, 0x1e, 0x01,
    124. 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff, 0xff, 0xfc,
    125. 0xfd, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    126. 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08,
    127. 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    128. 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xf0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff};


    Auf der Seite mit dem Converter ist auch der JavaScript Code im Quelltext verfügbar, ich werde aus diesem aber irgendwie nicht schlau und scheitere beim übersetzen.

    Hier ein Teil des Codes des am ESP32:

    C-Quellcode

    1. const char * WifiConnector::GetImage(char *deviceId)
    2. {
    3. WiFiClient wifi;
    4. HttpClient client = HttpClient(wifi, ApiHostname, ApiPort);
    5. int status = WL_IDLE_STATUS;
    6. Serial.println("making GET request");
    7. String uri = String(ApiBasePath) + String(ApiRegisterDevicePath) + "?serial=" + String(deviceId);
    8. Serial.println(uri);
    9. //sprintf(uri, "%s%s?serial=%s", ApiBasePath,ApiRegisterDevicePath,deviceId);
    10. client.get(uri);
    11. // read the status code and body of the response
    12. int statusCode = client.responseStatusCode();
    13. String response = client.responseBody();
    14. Serial.print("Status code: ");
    15. Serial.println(statusCode);
    16. Serial.print("Response: ");
    17. Serial.println(response);
    18. Serial.println("Return response");
    19. return response.c_str();
    20. }


    Hat jemand eine Idee wie ich hier weiterkommen könnte?

    Grüße
    Sascha
    If _work = worktype.hard Then Me.Drink(Coffee)
    Seht euch auch meine Tutorialreihe <WPF Lernen/> an oder abonniert meinen YouTube Kanal.

    ## Bitte markiere einen Thread als "Erledigt" wenn deine Frage beantwortet wurde. ##

    @Nofear23m Schau Dir mal dies an, ist nicht auf Vollständigkeit überprüft:
    Spoiler anzeigen

    C#-Quellcode

    1. using System;
    2. using System.Diagnostics;
    3. using System.IO;
    4. using System.Runtime.InteropServices;
    5. using System.Windows.Media;
    6. using System.Windows.Media.Imaging;

    C#-Quellcode

    1. /// <summary>
    2. /// Reads an image from disk and converts it to 16 BPP grey pixel data
    3. /// </summary>
    4. /// <param name="fileName">path and name of the file</param>
    5. /// <param name="values16">memory to store the 16 BPP mono image</param>
    6. /// <param name="width">out: width of the image</param>
    7. /// <param name="height">out: height of the image</param>
    8. /// <returns>Success</returns>
    9. public static bool ReadPictureGrey16(string fileName, out ushort[] values16, out int width, out int height)
    10. {
    11. values16 = null;
    12. width = 0;
    13. height = 0;
    14. if (string.IsNullOrEmpty(fileName))
    15. {
    16. Debug.Assert(false, "Path is empty");
    17. return false;
    18. }
    19. #region WPF-Format
    20. using (Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
    21. {
    22. BitmapFrame image = null;
    23. try
    24. {
    25. BitmapDecoder decoder = null;
    26. decoder = BitmapDecoder.Create(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None);
    27. image = decoder.Frames[0];
    28. }
    29. #if DEBUG
    30. catch (Exception ex)
    31. {
    32. // not supported format
    33. Console.WriteLine(ex.Message);
    34. return false;
    35. }
    36. #else
    37. catch
    38. {
    39. // not supported format
    40. return false;
    41. }
    42. #endif
    43. width = image.PixelWidth;
    44. height = image.PixelHeight;
    45. int stride = (width * image.Format.BitsPerPixel + 7) / 8;
    46. // Speicher für das Bild
    47. values16 = new ushort[height * width];
    48. // bmp.Format ist kein enum
    49. if (image.Format == PixelFormats.Gray16)
    50. {
    51. // 16 BPP
    52. image.CopyPixels(values16, stride, 0);
    53. }
    54. else if ((image.Format.BitsPerPixel == 8) ||
    55. (image.Format.BitsPerPixel == 24) ||
    56. (image.Format.BitsPerPixel == 32))
    57. {
    58. byte[] pixels8 = new byte[image.PixelHeight * image.PixelWidth];
    59. if (image.Format.BitsPerPixel == 8)
    60. {
    61. // 8 BPP-Formate werden explizit als solche eingelesen
    62. image.CopyPixels(pixels8, stride, 0);
    63. }
    64. else
    65. {
    66. // "normale" Farbbilder werden explizit nach Gray8 konvertiert
    67. FormatConvertedBitmap newImage = new FormatConvertedBitmap(image, PixelFormats.Gray8, null, 0.0);
    68. stride = width;
    69. newImage.CopyPixels(pixels8, stride, 0);
    70. newImage = null;
    71. }
    72. // Übertragen in den Arbeitsspeicher
    73. for (int i = 0; i < values16.Length; i++)
    74. {
    75. values16[i] = pixels8[i];
    76. }
    77. }
    78. else
    79. {
    80. // 16 BPP *.bmp würden hier landen
    81. // Alle anderen Formate werden explizit nach Gray16 konvertiert
    82. FormatConvertedBitmap newImage = new FormatConvertedBitmap(image, PixelFormats.Gray16, null, 0.0);
    83. // 16 BPP
    84. stride = width * 2;
    85. newImage.CopyPixels(values16, stride, 0);
    86. newImage = null;
    87. }
    88. return true;
    89. }
    90. #endregion WPF-Format
    91. }
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!

    Bluespide schrieb:

    wie kann denn bei dem einen das Bild angezeigt werden und beim anderen nicht, wenn die Array völlig identisch sind?

    Meine API gibt leider trotzdem nicht das zurück was ich gerne hätte.


    RodFromGermany schrieb:

    Schau Dir mal dies an

    Danke. Werde ich mal versuchen und gebe Rückmeldung.

    Grüße
    Sascha
    If _work = worktype.hard Then Me.Drink(Coffee)
    Seht euch auch meine Tutorialreihe <WPF Lernen/> an oder abonniert meinen YouTube Kanal.

    ## Bitte markiere einen Thread als "Erledigt" wenn deine Frage beantwortet wurde. ##

    Danke @RodFromGermany

    Leider finde ich keinen Weg "PresentationCore" in meiner ASP.Net Core API zu verwenden.

    Ich glaube das mein Fehler darin liegt das ich immer entweder ein char[] oder ein byte[] zurückgebe.
    Ich glaube ich müsste aber ein unsigned byte[] zurückgeben. Wie gesagt, ich werde aus dem JavaScript Code nicht schlau wie ich den in C# aber ich denke das hier mein Fehler liegen könnte.

    Kann das sein?

    Grüße
    Sascha
    If _work = worktype.hard Then Me.Drink(Coffee)
    Seht euch auch meine Tutorialreihe <WPF Lernen/> an oder abonniert meinen YouTube Kanal.

    ## Bitte markiere einen Thread als "Erledigt" wenn deine Frage beantwortet wurde. ##

    Danke für die Aufklärung, ich habe so selten mit solchen Datentypen zu tun das ich mir das noch nie so richtig angesehen habe.
    Komisch ist eben das ich in Postman so einen merkwürdigen Response bekomme wenn ich ein Byte[] zurückgebe.

    Das muss ich mal nochmal auf die Suche gehen warum dem so ist. Ich denke das hier genauso der Fehler liegen könnte.
    Das ich also eh im Code alles soweit richtig mache aber evtl. ein Encoding oder sowas mir einen Strich durch die Rechnung macht.

    Grüße
    If _work = worktype.hard Then Me.Drink(Coffee)
    Seht euch auch meine Tutorialreihe <WPF Lernen/> an oder abonniert meinen YouTube Kanal.

    ## Bitte markiere einen Thread als "Erledigt" wenn deine Frage beantwortet wurde. ##

    Sieht ja so aus, also würdest du das Byte Array als Base64 String zurück geben. Soll das so? Macht das ASP.Net Core automatisch? Byte-Arrays als Base64 zurück geben? Eventuell erwartest du das Array direkt als Response-Stream.

    Sowas in der Art:

    C#-Quellcode

    1. ​public async Task<IActionResult> SomeAction(....) {
    2. //...
    3. var bytes = await imagesService.GetArtistImageAsync(imageId);
    4. return File(bytes, "image/jpeg");
    5. }

    Return a FileResult from a byte[]

    Nofear23m schrieb:

    Leider finde ich keinen Weg "PresentationCore" in meiner ASP.Net Core API zu verwenden.
    Tut mir Leid, aber von ASP habe ich keine Ahnung. :/
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Ich hab da mal was gemacht, krieg meinen Rechner erst in ein paar Tagen wieder um Code zu hier rein zu kopieren.
    Auf jeden Fall hab ich eine Bitmap mit dem Parameter pixelformat24bpp erstellt. Per memory stream kann man die Bitmap in ein Byte array kopieren. Im array sind dann die Pixel im r, G, b Format zu finden wobei jeder farbwert ein Byte ist... Somit sind die rot-Werte immer an index 0,3,6,... Usw
    Der Beitrag wurde aus 100% wiederverwendbaren Elektronen erstellt!
    Hallo

    Danke für die Antworten.
    Nun bin ich schon weiter und mir wird zumindest nicht mehr nur Salat angezeigt.

    Bluespide schrieb:

    Eventuell erwartest du das Array direkt als Response-Stream.


    Danke, das was DER Tipp das hier mal ein Bild rüberkommt.

    Folgenden Code habe ich im Moment in meiner API:

    C#-Quellcode

    1. Bitmap bmp = new Bitmap(480, 800);
    2. using (Graphics g = Graphics.FromImage(bmp))
    3. {
    4. Font font = new Font("Arial", 35, FontStyle.Bold, GraphicsUnit.Point);
    5. g.Clear(Color.White);
    6. g.DrawRectangle(new Pen(Color.Black), new Rectangle(0, 0, 480-1, 800-1));
    7. g.DrawString("Lorem Ipsum", font, Brushes.Black, 5, 5);
    8. g.DrawString("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. ÜÖÄ'*?ß!§$%&/()=²³µ€@*+~'#123456789",
    9. new Font("Arial", 15, FontStyle.Regular, GraphicsUnit.Point), Brushes.Black, new RectangleF( 5, 80,470,720));
    10. }
    11. bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
    12. System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
    13. Bitmap newBitmap = new Bitmap(bmp.Width, bmp.Height, bmpData.Stride, System.Drawing.Imaging.PixelFormat.Format1bppIndexed, bmpData.Scan0);
    14. //newBitmap.Save(@"D:\x.jpg");
    15. return File(ImageToByte2(newBitmap), "image/bmp");


    C#-Quellcode

    1. public static byte[] ImageToByte2(Image img)
    2. {
    3. using (var stream = new MemoryStream())
    4. {
    5. img.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
    6. return stream.ToArray();
    7. }
    8. }


    Kann hier Live angerufen werden.

    Das generiert folgendes Bild am Display. Ist also versetzt und komischerweise gespiegelt.


    Scheint also irgendwas noch nicht ganz korrekt zu sein, aber ich komme der Sache näher. ;)
    Der Code am Microcontroller scheint aber zu passen, ersetzte ich nämlich einfach die Zeile an welcher das Bild zugewiesen wird mit dem Bild welches ins den Codebeispielen von Waveshare dabei ist dann wird dieses korrekt angezeigt.

    Komische Sache.
    If _work = worktype.hard Then Me.Drink(Coffee)
    Seht euch auch meine Tutorialreihe <WPF Lernen/> an oder abonniert meinen YouTube Kanal.

    ## Bitte markiere einen Thread als "Erledigt" wenn deine Frage beantwortet wurde. ##

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Nofear23m“ ()

    Hallo,
    kannst du nicht einfach mit dem Stream direkt arbeiten und diesen zurückliefern? Ist doch unnötig das in ein Byte-Array zu konvertieren, wenn es sich bereits um Bytes handelt.

    C#-Quellcode

    1. ​[HttpGet]
    2. public IActionResult Get()
    3. {
    4. var newBitmap = CreateBitmap();
    5. var ms = new MemoryStream();
    6. newBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
    7. ms.Seek(0, SeekOrigin.Begin);
    8. return new FileStreamResult(ms, "image/bmp");
    9. }

    Nofear23m schrieb:

    ersetzte ich nämlich einfach die Zeile an welcher das Bild zugewiesen wird mit dem Bild welches ins den Codebeispielen von Waveshare dabei ist dann wird dieses korrekt angezeigt.
    Wo welche? Das habe ich nicht genau verstanden. Kannst den Code nochmal posten?
    Ist es richtig, dass du das als BMP zurück sendest? Sind ja nicht wieder exakt die Pixeldaten aus dem Scan0, sondern BMP codiert. Ich hätte jetzt per Marshal das in ein Byte-Array kopiert und zurück gegeben. Aber passt vermutlich in etwa auch mit BMP? Wobei, BMP hat ja auch wieder einen BMP-Header oben dran, den er eventuell als PixelDaten interpretiert? Daher wollte ich den Code sehen mit dem es klappt.

    Ps: Font, Bitmap müssen auch Disposed werden, genau wie Graphics und wenn du mit dem LockBits fertig bist musst du auf dem Bitmap wieder UnlockBits aufrufen.
    Danke für die tolle Hilfe

    ISliceUrPanties schrieb:

    Ist doch unnötig das in ein Byte-Array zu konvertieren, wenn es sich bereits um Bytes handelt.

    Haste recht. Habe ich umgebaut, Ergebnis ist das selbe, aber der Code ist sabuerer.

    Bluespide schrieb:

    Kannst den Code nochmal posten?

    OK, anbei ein Beispiel, eines Bildes welches Mitgeliefert wird. Wird der Code so wie er ist reinkopiert und die Variable als Bild zugewiesen funktioniert das super.
    Anbei auch ein Foto wie das dann am Display aussieht.

    -Franky- schrieb:

    Das könnte die Spiegelung der Ausgabe erklären.

    Das kann ein super Hinweis. sein.
    Ich habe nun auch etwas interessantes gefunden was helfen könnte, bin aber noch am schaun wie ich das dann genau übergeben kann das es am Endgerät richtig ankommt.

    Hier ein Projekt welches Bilder in solch einen Code umwandeln kann, die Frage ist ob es was bringt wenn ich den "generierten Code" dann so als String über http ermittle und in ein unsigned char * caste, denn vom httpClient bekomme ich ja nur String zurück.
    Ich habe den Code schon mal adaptiert das ich den generierten String zurück bekomme. Aber ich denke ich muss es so umbauen das ich das ByteArray zurückbekomme.
    Kann natürlich auch sein das ich mich verlaufe.

    Spoiler anzeigen

    C#-Quellcode

    1. enum TransformColorFormats
    2. {
    3. BW_1bpp_H, // 8 pixels in width
    4. BW_1bpp_V, // 8 pixels in height
    5. BW_1bpp_C, // Horisontal read line-by-line to byte array
    6. RGB_332,
    7. RGB_444,
    8. RGB_565,
    9. }
    10. private string ImageToCode(Image img,TransformColorFormats tcf)
    11. {
    12. StringBuilder result = new StringBuilder();
    13. string codeFormat = "";
    14. int Width = 0, Height = 0;
    15. int bitInBlock = 7; // For BW/1bpp conversion
    16. bool is_1bpp = false;
    17. Image image = null;
    18. image = img;
    19. Width = (int)img.Width;
    20. Height = (int)img.Height;
    21. // Some additional checks
    22. if (tcf == TransformColorFormats.BW_1bpp_H && Width % 8 != 0)
    23. {
    24. throw new Exception("Error:\nWidth has to be multiple 8!");
    25. return null;
    26. }
    27. if (tcf == TransformColorFormats.BW_1bpp_V && Height % 8 != 0)
    28. {
    29. throw new Exception("Error:\nHeight has to be multiple 8!");
    30. return null;
    31. }
    32. switch (tcf)
    33. {
    34. case TransformColorFormats.BW_1bpp_H:
    35. case TransformColorFormats.BW_1bpp_V:
    36. case TransformColorFormats.BW_1bpp_C:
    37. //result.Append("uint8_t");
    38. codeFormat = "0x{0:x2}, ";
    39. is_1bpp = true;
    40. break;
    41. case TransformColorFormats.RGB_332:
    42. result.Append("uint8_t");
    43. codeFormat = "0x{0:x2}, ";
    44. break;
    45. case TransformColorFormats.RGB_444:
    46. case TransformColorFormats.RGB_565:
    47. result.Append("uint16_t");
    48. codeFormat = "0x{0:x4}, ";
    49. break;
    50. default:
    51. throw new Exception("Sorry, unsupported format");
    52. return null;
    53. }
    54. //result.Append(" image = {" + Environment.NewLine + "\t");
    55. using (Bitmap bmp = new Bitmap(image, Width, Height))
    56. {
    57. int rowPos = 0;
    58. int pixelsTotal = bmp.Width * bmp.Height;
    59. int pixelsCurrent = 0;
    60. int ColorByte = 0;
    61. // ===========================================================
    62. // Optimisation: Upto 5x faster than GetPixel();
    63. Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
    64. System.Drawing.Imaging.BitmapData bmpData =
    65. bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
    66. bmp.PixelFormat);
    67. IntPtr ptr = bmpData.Scan0;
    68. int bytes = bmpData.Stride * bmp.Height; // ARGB: Width * Height * 4 (Stride = Width * 4)
    69. byte[] rgbValues = new byte[bytes];
    70. // Format BGRA (GRB+Alpha, inverted). Example: BBBBBBBB GGGGGGGG RRRRRRRR AAAAAAAA
    71. System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
    72. int pixelByte = 0;
    73. // ===========================================================
    74. // Read image pixel's from left to right, top to bottom (Like a book)
    75. for (int y = 0; y < bmp.Height; y++)
    76. {
    77. for (int x = 0; x < bmp.Width; x++)
    78. {
    79. pixelByte = (y * bmp.Width + x) * 4;
    80. switch (tcf)
    81. {
    82. case TransformColorFormats.BW_1bpp_V:
    83. for (int px = 0; px < 7; px++)
    84. {
    85. pixelByte = ((y + px) * bmp.Width + x) * 4;
    86. if (rgbValues[pixelByte + 2] > 128 || // Red
    87. rgbValues[pixelByte + 1] > 128 || // Green
    88. rgbValues[pixelByte + 0] > 128) // Blue
    89. ColorByte &= ~(1 << px); // White/remove
    90. else
    91. ColorByte |= 1 << px; // Black/set
    92. }
    93. bitInBlock = 0;
    94. break;
    95. case TransformColorFormats.BW_1bpp_H:
    96. case TransformColorFormats.BW_1bpp_C:
    97. if (rgbValues[pixelByte + 2] > 128 || // Red
    98. rgbValues[pixelByte + 1] > 128 || // Green
    99. rgbValues[pixelByte + 0] > 128) // Blue
    100. ColorByte &= ~(1 << bitInBlock); // White/remove
    101. else
    102. ColorByte |= 1 << bitInBlock; // Black/set
    103. break;
    104. case TransformColorFormats.RGB_332:
    105. ColorByte =
    106. (rgbValues[pixelByte + 2] & 0xE0) | // 0xE0 = 1110 0000
    107. (rgbValues[pixelByte + 1] & 0xE0) >> 3 |
    108. (rgbValues[pixelByte + 0] & 0xC0) >> 6; // 0xC0 = 1100 0000
    109. break;
    110. case TransformColorFormats.RGB_444:
    111. // byte = 16 bit per color
    112. // RRRR RGGG GGGB BBBB
    113. ColorByte =
    114. (rgbValues[pixelByte + 2] & 0xF0) << 4 | // 0xF0 = 1111 0000
    115. (rgbValues[pixelByte + 1] & 0xF0) |
    116. (rgbValues[pixelByte + 0] & 0xF0) >> 4;
    117. break;
    118. case TransformColorFormats.RGB_565:
    119. // byte = 16 bit per color
    120. // RRRR RGGG GGGB BBBB
    121. ColorByte =
    122. (rgbValues[pixelByte + 2] & 0xF8) << 8 | // 0xF8 = 1111 1000
    123. (rgbValues[pixelByte + 1] & 0xFC) << 3 | // 0xFC = 1111 1100
    124. (rgbValues[pixelByte + 0] & 0xF8) >> 3;
    125. break;
    126. }
    127. if (!is_1bpp || bitInBlock == 0)
    128. {
    129. result.AppendFormat(codeFormat, ColorByte);
    130. pixelsCurrent++;
    131. rowPos++;
    132. if (rowPos == 16)
    133. {
    134. rowPos = 0;
    135. result.Append(Environment.NewLine + "\t");
    136. }
    137. bitInBlock = 7; // BW/1bpp bit position reset
    138. ColorByte = 0; // Reset data
    139. }
    140. else
    141. {
    142. bitInBlock--;
    143. }
    144. }
    145. if (tcf == TransformColorFormats.BW_1bpp_V)
    146. {
    147. y += 7;
    148. }
    149. //bgWork.ReportProgress((int)((double)pixelsCurrent / (double)pixelsTotal * 100));
    150. }
    151. }
    152. result.Append(Environment.NewLine + "};");
    153. return result.ToString();
    154. }
    Dateien
    • Dokumente.zip

      (2,35 MB, 35 mal heruntergeladen, zuletzt: )
    If _work = worktype.hard Then Me.Drink(Coffee)
    Seht euch auch meine Tutorialreihe <WPF Lernen/> an oder abonniert meinen YouTube Kanal.

    ## Bitte markiere einen Thread als "Erledigt" wenn deine Frage beantwortet wurde. ##

    Ist ja witzig, wenn ich das Array zurück in ein Bitmap schreibe dann hat das schon im Bild diesen Versatz, also ob er das schon automatisch ausgleicht.





    Edit: Doch nicht, du hast ja oben ein paar Bytes auskommentiert, das hatte ich falsch kopiert.
    Aber wie hast du das Array ins Bitmap bekommen? Diese Stelle meinte ich.

    Also meine Frage zielte eigentlich darauf ab, ob du bei dem funktionierenden Bild einfach das Array zurück gibst oder auch ein BMP. Aber das habe ich glaube ich schon gerade selbst beantwortet. Da nur ein paar Bytes zu viel am Anfang schon so einen Offset bringen.
    Also ein Bitmap über BMP in einen MemoryStream Saven gibt dir nicht die reinen Pixeldaten, die du aber haben willst. Daher der Offset und mit der Anmerkung von @-Franky- zusammen erklärt sich dann auch die Spiegelung. Benutzt du .NET 6 oder .Net Fx 4.8?

    Edit2:
    Eigentlich auch egal, kannst du das mal probieren?:

    C#-Quellcode

    1. byte[] data = null;
    2. using (Bitmap bmp = new Bitmap(480, 800)) {
    3. using (Graphics g = Graphics.FromImage(bmp)) {
    4. g.Clear(Color.White);
    5. using (Pen p = new Pen(Color.Black)) {
    6. g.DrawRectangle(p, new Rectangle(0, 0, 480 - 1, 800 - 1));
    7. }
    8. using (Font font = new Font("Arial", 35, FontStyle.Bold, GraphicsUnit.Point)) {
    9. g.DrawString("Lorem Ipsum", font, Brushes.Black, 5, 5);
    10. }
    11. using (Font font = new Font("Arial", 15, FontStyle.Regular, GraphicsUnit.Point)) {
    12. g.DrawString("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. ÜÖÄ'*?ß!§$%&/()=²³µ€@*+~'#123456789", font, Brushes.Black, new RectangleF(5, 80, 470, 720));
    13. }
    14. }
    15. bmp.RotateFlip(RotateFlipType.Rotate90FlipX);
    16. System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
    17. data = new byte[bmp.Width * bmp.Height / 8];
    18. System.Runtime.InteropServices.Marshal.Copy(bmpData.Scan0, data, 0, data.Length);
    19. bmp.UnlockBits(bmpData);
    20. }
    21. return File(data, "image/bmp");

    Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „Bluespide“ ()

    @Bluespide
    Du bist gerade zu meinem Held geworden!

    Das war die Lösung.
    In diesem Fall benötige ich Flip nicht mal und es reicht: bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);

    Damit ich das verstehe auch. Ich muss ja zugeben mit Hardwarenaher Programmierung hatte ich bis Dato wenig am Hut und auf Ebenen rund um Bit und Byte war ich bisher wenig unterwegs.
    War es im Endeffekt die Tatsache das du mit data = new byte[bmp.Width * bmp.Height / 8]; die Anzahl der Bytes fixierst oder was?



    Ich bin gerade voll Happy.

    Wenn ich jetzt noch ne Komprimierung auch noch hinbekomme ist das wie Weihnachten. ;)

    GRüße
    Sascha

    Edit: Der Browser kanns jetzt zwar nicht mehr lesen, das ist mir aber schnuppe ;)
    Hier eine TestUri: spsonline.ddns.net/cupcakeapi/…/DeviceMessage?serial=VBP
    If _work = worktype.hard Then Me.Drink(Coffee)
    Seht euch auch meine Tutorialreihe <WPF Lernen/> an oder abonniert meinen YouTube Kanal.

    ## Bitte markiere einen Thread als "Erledigt" wenn deine Frage beantwortet wurde. ##

    Super, das freut mich!

    Ist also wirklich so, dass du direkt die Pixel-Daten im dem Stream Brauchst.
    data = new byte[bmp.Width * bmp.Height / 8]; mache ich nur um die Größe des Arrays zu bestimmen, nicht zum begrenzen.
    Jedes Bit zählt also als ein Pixel: 0 = schwarz und 1 = weiß. Da ein byte ja 8 bit hat stecken hinter einem byte also 8 Pixel. Damit ist die Größe in Bytes: Breite * Höhe / 8.

    Das Problem vorher war das newBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); hier speicherst du das Bild im Bmp-Format mit Header (alle Formate haben Header). Dieser Header vorne dran wird von deinem Controller aber direkt als Pixel-Daten interpretiert, da er direkt die Pixel-Daten im Stream erwartet. Das hat das ganze Bild verschoben und das Ende abgeschnitten. Mit dem LockBits bekommst du aber einen Pointer direkt auf die Pixel-Daten in dem Bitmap, daher kopiere ich die von da direkt in das Array.

    Der Controller interpretiert anscheint kein richtiges Image-Format sondern nur direkt die Pixel-Daten. Das müsstest du dem erst beibringen, damit der Browser eine Change hat das Bild auch wieder anzuzeigen oder du eine Komprimierung rein bringen kannst.
    Hi

    Hmm, die Berechnung w * h / 8 könnte falsche Werte liefern wenn w kein vielfaches von 8 ist. Normal rechnest Stride * h. Wenn Du sowieso ein LockBits auf die 1bppIndexed Bitmap machst um die Pixeldaten zu kopieren, kommst doch direkt über BitmapData an den Stride-Wert. Den mal h und Du hast die Größe für das ByteArray.
    Mfg -Franky-
    Hallo

    Danke für die erläuterungen, jetzt verstehe ich es besser.

    Das mit der Berechnung ist für meinen Fall im Grunde egal da alle Displays eine Auflösung haben die teilbar durch 8 ist.
    Wird wohl seinen Grund haben denke ich.

    Ich freu mich jedenfalls das es klappt.

    Grüße
    Sascha
    If _work = worktype.hard Then Me.Drink(Coffee)
    Seht euch auch meine Tutorialreihe <WPF Lernen/> an oder abonniert meinen YouTube Kanal.

    ## Bitte markiere einen Thread als "Erledigt" wenn deine Frage beantwortet wurde. ##