Lines Matching defs:buffer

253 /*you can both convert from vector to buffer&size and vica versa. If you use
254 init_buffer to take over a buffer and size, it is not needed to use cleanup*/
255 static void ucvector_init_buffer(ucvector* p, unsigned char* buffer, size_t size)
257 p->data = buffer;
319 unsigned lodepng_read32bitInt(const unsigned char* buffer)
321 return (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
325 /*buffer must have at least 4 allocated bytes available*/
326 static void lodepng_set32bitInt(unsigned char* buffer, unsigned value)
328 buffer[0] = (unsigned char)((value >> 24) & 0xff);
329 buffer[1] = (unsigned char)((value >> 16) & 0xff);
330 buffer[2] = (unsigned char)((value >> 8) & 0xff);
331 buffer[3] = (unsigned char)((value ) & 0xff);
336 static void lodepng_add32bitInt(ucvector* buffer, unsigned value)
338 ucvector_resize(buffer, buffer->size + 4); /*todo: give error if resize failed*/
339 lodepng_set32bitInt(&buffer->data[buffer->size - 4], value);
376 /*write given buffer to the file, overwriting the file, it doesn't append to it.*/
377 unsigned lodepng_save_file(const unsigned char* buffer, size_t buffersize, const char* filename)
382 fwrite((char*)buffer , 1 , buffersize, file);
900 inbitlength is the length of the complete buffer, in bits (so its byte length times 8)
1207 /*read the literal data: LEN bytes are now stored in the out buffer*/
1208 if(p + LEN > inlength) return 23; /*error: reading outside of in buffer*/
1223 size_t pos = 0; /*byte position in the out buffer*/
1488 /*stop when went completely around the circular buffer*/
2137 that's pointing to a non allocated buffer, this'll crash*/
2153 /*ucvector-controlled version of the output buffer, for dynamic array*/
3210 to RGBA or RGB with 8 bit per cannel. buffer must be RGBA or RGB output with
3212 of the input buffer.*/
3213 static unsigned getPixelColorsRGBA8(unsigned char* buffer, size_t numpixels,
3224 for(i = 0; i < numpixels; i++, buffer += num_channels)
3226 buffer[0] = buffer[1] = buffer[2] = in[i];
3227 if(has_alpha) buffer[3] = mode->key_defined && in[i] == mode->key_r ? 0 : 255;
3232 for(i = 0; i < numpixels; i++, buffer += num_channels)
3234 buffer[0] = buffer[1] = buffer[2] = in[i * 2];
3235 if(has_alpha) buffer[3] = mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r ? 0 : 255;
3242 for(i = 0; i < numpixels; i++, buffer += num_channels)
3245 buffer[0] = buffer[1] = buffer[2] = (value * 255) / highest;
3246 if(has_alpha) buffer[3] = mode->key_defined && value == mode->key_r ? 0 : 255;
3254 for(i = 0; i < numpixels; i++, buffer += num_channels)
3256 buffer[0] = in[i * 3 + 0];
3257 buffer[1] = in[i * 3 + 1];
3258 buffer[2] = in[i * 3 + 2];
3259 if(has_alpha) buffer[3] = mode->key_defined && buffer[0] == mode->key_r
3260 && buffer[1]== mode->key_g && buffer[2] == mode->key_b ? 0 : 255;
3265 for(i = 0; i < numpixels; i++, buffer += num_channels)
3267 buffer[0] = in[i * 6 + 0];
3268 buffer[1] = in[i * 6 + 2];
3269 buffer[2] = in[i * 6 + 4];
3270 if(has_alpha) buffer[3] = mode->key_defined
3281 for(i = 0; i < numpixels; i++, buffer += num_channels)
3290 buffer[0] = buffer[1] = buffer[2] = 0;
3291 if(has_alpha) buffer[3] = 255;
3295 buffer[0] = mode->palette[index * 4 + 0];
3296 buffer[1] = mode->palette[index * 4 + 1];
3297 buffer[2] = mode->palette[index * 4 + 2];
3298 if(has_alpha) buffer[3] = mode->palette[index * 4 + 3];
3306 for(i = 0; i < numpixels; i++, buffer += num_channels)
3308 buffer[0] = buffer[1] = buffer[2] = in[i * 2 + 0];
3309 if(has_alpha) buffer[3] = in[i * 2 + 1];
3314 for(i = 0; i < numpixels; i++, buffer += num_channels)
3316 buffer[0] = buffer[1] = buffer[2] = in[i * 4 + 0];
3317 if(has_alpha) buffer[3] = in[i * 4 + 2];
3325 for(i = 0; i < numpixels; i++, buffer += num_channels)
3327 buffer[0] = in[i * 4 + 0];
3328 buffer[1] = in[i * 4 + 1];
3329 buffer[2] = in[i * 4 + 2];
3330 if(has_alpha) buffer[3] = in[i * 4 + 3];
3335 for(i = 0; i < numpixels; i++, buffer += num_channels)
3337 buffer[0] = in[i * 8 + 0];
3338 buffer[1] = in[i * 8 + 2];
3339 buffer[2] = in[i * 8 + 4];
3340 if(has_alpha) buffer[3] = in[i * 8 + 6];
3390 the out buffer must have (w * h * bpp + 7) / 8 bytes, where bpp is the bits per pixel of the output color type
4157 size_t obp, ibp; /*bit pointers (for out and in buffer)*/
4166 /*note that this function assumes the out buffer is completely 0, use setBitOfReversedStream otherwise*/
4181 in and out are allowed to be the same buffer, in may also be higher but still overlapping; in must
4201 /*out must be buffer big enough to contain full image, and in must contain the full decompressed data from
4208 This function converts the filtered-padded-interlaced data into pure 2D image buffer with the PNG's colortype.
4212 NOTE: the in buffer will be overwritten with intermediate data!
4224 /*we can immediatly filter into the out buffer, no other steps needed*/
4588 IDAT data is put at the start of the in buffer*/
4594 /*error: size of the in buffer too small to contain next chunk*/
4604 CERROR_BREAK(state->error, 64); /*error: size of the in buffer too small to contain next chunk*/
4808 unsigned char* buffer;
4811 error = lodepng_load_file(&buffer, &buffersize, filename);
4812 if(!error) error = lodepng_decode_memory(out, w, h, buffer, buffersize, colortype, bitdepth);
4813 lodepng_free(buffer);
5236 out must be a buffer with as size: h + (w * h * bpp + 7) / 8, because there are
5517 size_t obp, ibp; /*bit pointers (for out and in buffer)*/
5533 /*out must be buffer big enough to contain uncompressed IDAT chunk data, and in must contain the full image.
5569 /*we can immediatly filter into the out buffer, no other steps needed*/
5885 unsigned char* buffer;
5887 unsigned error = lodepng_encode_memory(&buffer, &buffersize, image, w, h, colortype, bitdepth);
5888 if(!error) error = lodepng_save_file(buffer, buffersize, filename);
5889 lodepng_free(buffer);
5938 case 17: return "end of out buffer memory reached while inflating";
5940 case 19: return "end of out buffer memory reached while inflating";
5943 /*end of out buffer memory reached while inflating:
5947 case 22: return "end of out buffer memory reached while inflating";
5948 case 23: return "end of in buffer memory reached while inflating";
6010 case 77: return "integer overflow in buffer size";
6041 void load_file(std::vector<unsigned char>& buffer, const std::string& filename)
6051 buffer.resize(size_t(size));
6052 if(size > 0) file.read((char*)(&buffer[0]), size);
6055 /*write given buffer to the file, overwriting the file, it doesn't append to it.*/
6056 void save_file(const std::vector<unsigned char>& buffer, const std::string& filename)
6059 file.write(buffer.empty() ? 0 : (char*)&buffer[0], std::streamsize(buffer.size()));
6068 unsigned char* buffer = 0;
6070 unsigned error = zlib_decompress(&buffer, &buffersize, in, insize, &settings);
6071 if(buffer)
6073 out.insert(out.end(), &buffer[0], &buffer[buffersize]);
6074 lodepng_free(buffer);
6090 unsigned char* buffer = 0;
6092 unsigned error = zlib_compress(&buffer, &buffersize, in, insize, &settings);
6093 if(buffer)
6095 out.insert(out.end(), &buffer[0], &buffer[buffersize]);
6096 lodepng_free(buffer);
6139 unsigned char* buffer;
6140 unsigned error = lodepng_decode_memory(&buffer, &w, &h, in, insize, colortype, bitdepth);
6141 if(buffer && !error)
6147 out.insert(out.end(), &buffer[0], &buffer[buffersize]);
6148 lodepng_free(buffer);
6163 unsigned char* buffer = NULL;
6164 unsigned error = lodepng_decode(&buffer, &w, &h, &state, in, insize);
6165 if(buffer && !error)
6168 out.insert(out.end(), &buffer[0], &buffer[buffersize]);
6170 lodepng_free(buffer);
6185 std::vector<unsigned char> buffer;
6186 load_file(buffer, filename);
6187 return decode(out, w, h, buffer, colortype, bitdepth);
6196 unsigned char* buffer;
6198 unsigned error = lodepng_encode_memory(&buffer, &buffersize, in, w, h, colortype, bitdepth);
6199 if(buffer)
6201 out.insert(out.end(), &buffer[0], &buffer[buffersize]);
6202 lodepng_free(buffer);
6219 unsigned char* buffer;
6221 unsigned error = lodepng_encode(&buffer, &buffersize, in, w, h, &state);
6222 if(buffer)
6224 out.insert(out.end(), &buffer[0], &buffer[buffersize]);
6225 lodepng_free(buffer);
6243 std::vector<unsigned char> buffer;
6244 unsigned error = encode(buffer, in, w, h, colortype, bitdepth);
6245 if(!error) save_file(buffer, filename);