MCPcopy Create free account
hub / github.com/LibRaw/LibRaw / copy_mem_image

Method copy_mem_image

src/postprocessing/mem_image.cpp:186–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186int LibRaw::copy_mem_image(void *scan0, int stride, int bgr)
187
188{
189 // the image memory pointed to by scan0 is assumed to be in the format
190 // returned by get_mem_image_format
191 if ((imgdata.progress_flags & LIBRAW_PROGRESS_THUMB_MASK) <
192 LIBRAW_PROGRESS_PRE_INTERPOLATE)
193 return LIBRAW_OUT_OF_ORDER_CALL;
194
195 if (libraw_internal_data.output_data.histogram)
196 {
197 int perc, val, total, t_white = 0x2000, c;
198 perc = int(S.width * S.height * O.auto_bright_thr);
199 if (IO.fuji_width)
200 perc /= 2;
201 if (!((O.highlight & ~2) || O.no_auto_bright))
202 for (t_white = c = 0; c < P1.colors; c++)
203 {
204 for (val = 0x2000, total = 0; --val > 32;)
205 if ((total += libraw_internal_data.output_data.histogram[c][val]) >
206 perc)
207 break;
208 if (t_white < val)
209 t_white = val;
210 }
211 gamma_curve(O.gamm[0], O.gamm[1], 2, int((t_white << 3) / O.bright));
212 }
213
214 int s_iheight = S.iheight;
215 int s_iwidth = S.iwidth;
216 int s_width = S.width;
217 int s_hwight = S.height;
218
219 S.iheight = S.height;
220 S.iwidth = S.width;
221
222 if (S.flip & 4)
223 SWAP(S.height, S.width);
224 uchar *ppm;
225 ushort *ppm2;
226 int c, row, col, soff, rstep, cstep;
227
228 soff = flip_index(0, 0);
229 cstep = flip_index(0, 1) - soff;
230 rstep = flip_index(1, 0) - flip_index(0, S.width);
231
232 for (row = 0; row < S.height; row++, soff += rstep)
233 {
234 uchar *bufp = ((uchar *)scan0) + row * stride;
235 ppm2 = (ushort *)(ppm = bufp);
236 // keep trivial decisions in the outer loop for speed
237 if (bgr)
238 {
239 if (O.output_bps == 8)
240 {
241 for (col = 0; col < S.width; col++, soff += cstep)
242 FORBGR *ppm++ = imgdata.color.curve[imgdata.image[soff][c]] >> 8;
243 }

Callers

nothing calls this directly

Calls 1

gamma_curveFunction · 0.85

Tested by

no test coverage detected