MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / findImageFormat

Method findImageFormat

html/noteformatter.cpp:431–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

429
430
431const char* NoteFormatter::findImageFormat(QString file) {
432 QByteArray b;
433 QFile f(file);
434 f.open(QFile::ReadOnly);
435 b = f.read(10);
436 f.close();
437
438 // Try to determine the type of image from the "magic bytes"
439 if (b.startsWith("\xFF\xD8\xFF"))
440 return "JPG";
441 if (b.startsWith("\x89\x50\x4E\x47\x0D\x0A\x1A\x0A"))
442 return "PNG";
443 if (b.startsWith("GIF87a"))
444 return "GIF";
445 if (b.startsWith("GIF89a"))
446 return "GIF";
447 return 0;
448}
449
450
451

Callers

nothing calls this directly

Calls 3

openMethod · 0.80
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected