MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__pic_load_core

Function stbi__pic_load_core

include/stb/stb_image.h:6390–6498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6388}
6389
6390static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result)
6391{
6392 int act_comp=0,num_packets=0,y,chained;
6393 stbi__pic_packet packets[10];
6394
6395 // this will (should...) cater for even some bizarre stuff like having data
6396 // for the same channel in multiple packets.
6397 do {
6398 stbi__pic_packet *packet;
6399
6400 if (num_packets==sizeof(packets)/sizeof(packets[0]))
6401 return stbi__errpuc("bad format","too many packets");
6402
6403 packet = &packets[num_packets++];
6404
6405 chained = stbi__get8(s);
6406 packet->size = stbi__get8(s);
6407 packet->type = stbi__get8(s);
6408 packet->channel = stbi__get8(s);
6409
6410 act_comp |= packet->channel;
6411
6412 if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)");
6413 if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp");
6414 } while (chained);
6415
6416 *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel?
6417
6418 for(y=0; y<height; ++y) {
6419 int packet_idx;
6420
6421 for(packet_idx=0; packet_idx < num_packets; ++packet_idx) {
6422 stbi__pic_packet *packet = &packets[packet_idx];
6423 stbi_uc *dest = result+y*width*4;
6424
6425 switch (packet->type) {
6426 default:
6427 return stbi__errpuc("bad format","packet has bad compression type");
6428
6429 case 0: {//uncompressed
6430 int x;
6431
6432 for(x=0;x<width;++x, dest+=4)
6433 if (!stbi__readval(s,packet->channel,dest))
6434 return 0;
6435 break;
6436 }
6437
6438 case 1://Pure RLE
6439 {
6440 int left=width, i;
6441
6442 while (left>0) {
6443 stbi_uc count,value[4];
6444
6445 count=stbi__get8(s);
6446 if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)");
6447

Callers 1

stbi__pic_loadFunction · 0.85

Calls 5

stbi__get8Function · 0.85
stbi__at_eofFunction · 0.85
stbi__readvalFunction · 0.85
stbi__copyvalFunction · 0.85
stbi__get16beFunction · 0.85

Tested by

no test coverage detected