Skip to content

Commit f7522b9

Browse files
authored
fix ofPixels <float> allocation issue (#7936)
1 parent 2259444 commit f7522b9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libs/openFrameworks/graphics/ofPixels.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ void ofPixels_<PixelType>::setFromExternalPixels(PixelType * newPixels, size_t w
396396
width= w;
397397
height = h;
398398

399-
pixelsSize = bytesFromPixelFormat(w,h,_pixelFormat) / sizeof(PixelType);
399+
pixelsSize = bytesFromPixelFormat(w,h,_pixelFormat);
400400

401401
pixels = newPixels;
402402
pixelsOwner = false;
@@ -530,7 +530,7 @@ void ofPixels_<PixelType>::allocate(size_t w, size_t h, ofPixelFormat format){
530530
width = w;
531531
height = h;
532532

533-
pixelsSize = newSize / sizeof(PixelType);
533+
pixelsSize = newSize;
534534

535535
pixels = new PixelType[pixelsSize];
536536
bAllocated = true;
@@ -1323,6 +1323,9 @@ float ofPixels_<PixelType>::bicubicInterpolate (const float *patch, float x,floa
13231323
a20 * x2 + a21 * x2 * y + a22 * x2 * y2 + a23 * x2 * y3 +
13241324
a30 * x3 + a31 * x3 * y + a32 * x3 * y2 + a33 * x3 * y3;
13251325

1326+
if (std::is_floating_point<PixelType>::value) {
1327+
return std::min(1.0f, std::max(out, 0.0f));
1328+
}
13261329
return std::min(static_cast<size_t>(255), std::max(static_cast<size_t>(out), static_cast<size_t>(0)));
13271330
}
13281331

0 commit comments

Comments
 (0)