Skip to content

Commit 0ab21f7

Browse files
authored
Replace for loop by memset
1 parent 1008a83 commit 0ab21f7

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

png2xyz/src/png2xyz.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ int main(int argc, char* argv[]) {
204204
png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
205205

206206
xyz_data = new unsigned char[768 + width * height];
207+
memset(xyz_data, 0, 768);
207208

208209
// Create XYZ palette
209210
for (size_t i = 0; i < num_palette; i++) {
@@ -212,13 +213,6 @@ int main(int argc, char* argv[]) {
212213
xyz_data[i * 3 + 2] = palette[i].blue;
213214
}
214215

215-
// Create dummy palette entries, if PNG palette has less than 256 colors
216-
for (size_t i = num_palette; i < 256; i++) {
217-
xyz_data[i * 3] = 0;
218-
xyz_data[i * 3 + 1] = 0;
219-
xyz_data[i * 3 + 2] = 0;
220-
}
221-
222216
// Get image rows
223217
row_pointers = png_get_rows(png_ptr, info_ptr);
224218

0 commit comments

Comments
 (0)