From ce2c65a6916f6d83c3673529c2139a0a8acff15d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 7 Dec 2024 22:40:35 -0300 Subject: [PATCH 1/6] update pixelsSize --- libs/openFrameworks/graphics/ofPixels.cpp | 18 +++++++++--------- scripts/apothecary | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/openFrameworks/graphics/ofPixels.cpp b/libs/openFrameworks/graphics/ofPixels.cpp index de5d1847b6f..ff081c62d13 100644 --- a/libs/openFrameworks/graphics/ofPixels.cpp +++ b/libs/openFrameworks/graphics/ofPixels.cpp @@ -393,10 +393,10 @@ template void ofPixels_::setFromExternalPixels(PixelType * newPixels, size_t w, size_t h, ofPixelFormat _pixelFormat){ clear(); pixelFormat = _pixelFormat; - width= w; + width = w; height = h; - pixelsSize = bytesFromPixelFormat(w,h,_pixelFormat); + pixelsSize = w * h; pixels = newPixels; pixelsOwner = false; @@ -513,8 +513,8 @@ void ofPixels_::allocate(size_t w, size_t h, ofPixelFormat format){ return; } - size_t newSize = bytesFromPixelFormat(w,h,format); - size_t oldSize = getTotalBytes(); + size_t newSize = w * h; + size_t oldSize = size(); //we check if we are already allocated at the right size if(bAllocated && newSize==oldSize){ pixelFormat = format; @@ -583,11 +583,11 @@ void ofPixels_::clear(){ pixels = nullptr; } - width = 0; - height = 0; - pixelFormat = OF_PIXELS_UNKNOWN; - pixelsSize = 0; - bAllocated = false; + width = 0; + height = 0; + pixelFormat = OF_PIXELS_UNKNOWN; + pixelsSize = 0; + bAllocated = false; } template diff --git a/scripts/apothecary b/scripts/apothecary index 3e5d43b1ae5..3dd550a3238 160000 --- a/scripts/apothecary +++ b/scripts/apothecary @@ -1 +1 @@ -Subproject commit 3e5d43b1ae518270f93dc78546482ecb977eb9bd +Subproject commit 3dd550a323844c261f808f5de6671fc9d6e03586 From c4a9259fb43b66cd86ba0bc916228fca010a5586 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 7 Dec 2024 22:49:28 -0300 Subject: [PATCH 2/6] up --- libs/openFrameworks/graphics/ofPixels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/graphics/ofPixels.cpp b/libs/openFrameworks/graphics/ofPixels.cpp index ff081c62d13..ccfbc582c81 100644 --- a/libs/openFrameworks/graphics/ofPixels.cpp +++ b/libs/openFrameworks/graphics/ofPixels.cpp @@ -532,7 +532,7 @@ void ofPixels_::allocate(size_t w, size_t h, ofPixelFormat format){ pixelsSize = newSize; - pixels = new PixelType[pixelsSize]; + pixels = new PixelType[pixelsSize * getNumChannels()]; bAllocated = true; pixelsOwner = true; } From 896b5958759e471f591badbb845f5181ca7ea2ae Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 8 Dec 2024 00:07:08 -0300 Subject: [PATCH 3/6] update --- libs/openFrameworks/graphics/ofPixels.cpp | 9 ++++++--- libs/openFrameworks/graphics/ofPixels.h | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libs/openFrameworks/graphics/ofPixels.cpp b/libs/openFrameworks/graphics/ofPixels.cpp index ccfbc582c81..c97bc41be09 100644 --- a/libs/openFrameworks/graphics/ofPixels.cpp +++ b/libs/openFrameworks/graphics/ofPixels.cpp @@ -513,8 +513,8 @@ void ofPixels_::allocate(size_t w, size_t h, ofPixelFormat format){ return; } - size_t newSize = w * h; - size_t oldSize = size(); + size_t newSize = w * h * pixelBitsFromPixelFormat(format); + size_t oldSize = size() * pixelBitsFromPixelFormat(pixelFormat); //we check if we are already allocated at the right size if(bAllocated && newSize==oldSize){ pixelFormat = format; @@ -530,9 +530,12 @@ void ofPixels_::allocate(size_t w, size_t h, ofPixelFormat format){ width = w; height = h; - pixelsSize = newSize; + pixelsSize = w * h; + // we have some incongruence here, if we use PixelType + // we are not able to use RGB565 format pixels = new PixelType[pixelsSize * getNumChannels()]; +// pixels = new uint8_t[newSize]; bAllocated = true; pixelsOwner = true; } diff --git a/libs/openFrameworks/graphics/ofPixels.h b/libs/openFrameworks/graphics/ofPixels.h index 0d28f8f0ef6..06f15f69193 100644 --- a/libs/openFrameworks/graphics/ofPixels.h +++ b/libs/openFrameworks/graphics/ofPixels.h @@ -679,8 +679,8 @@ class ofPixels_ { void copyFrom( const ofPixels_& mom ); PixelType * pixels = nullptr; - size_t width = 0; - size_t height = 0; + size_t width = 0; + size_t height = 0; //int channels; // 1, 3, 4 channels per pixel (grayscale, rgb, rgba) size_t pixelsSize = 0; From 014187fb8a6fc4f4d61d066e8a95fa04e1649299 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 14 Dec 2024 22:11:32 -0300 Subject: [PATCH 4/6] submodule, merge master --- scripts/apothecary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/apothecary b/scripts/apothecary index b8b8325f8d0..900b6b48ffa 160000 --- a/scripts/apothecary +++ b/scripts/apothecary @@ -1 +1 @@ -Subproject commit b8b8325f8d060e5474248cb6c5c6bd24a6698307 +Subproject commit 900b6b48ffa98ec7d6a1f906b08e2fe82b09f4c6 From e1bc70c3da23177600a0f1a408d940508f6b97eb Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 28 Feb 2025 20:53:23 -0300 Subject: [PATCH 5/6] pixelsSize now is w * h * getNumChannels() --- libs/openFrameworks/graphics/ofPixels.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/openFrameworks/graphics/ofPixels.cpp b/libs/openFrameworks/graphics/ofPixels.cpp index c97bc41be09..21074f24ae5 100644 --- a/libs/openFrameworks/graphics/ofPixels.cpp +++ b/libs/openFrameworks/graphics/ofPixels.cpp @@ -143,7 +143,9 @@ static size_t channelsFromPixelFormat(ofPixelFormat format){ return 1; break; case OF_PIXELS_GRAY_ALPHA: - case OF_PIXELS_RGB565: + + // this is not true for OF_PIXELS_RGB565. it has 3 channels and 2 bytes. + // case OF_PIXELS_RGB565: return 2; break; case OF_PIXELS_NV12: @@ -396,7 +398,7 @@ void ofPixels_::setFromExternalPixels(PixelType * newPixels, size_t w width = w; height = h; - pixelsSize = w * h; + pixelsSize = w * h * getNumChannels(); pixels = newPixels; pixelsOwner = false; @@ -514,7 +516,7 @@ void ofPixels_::allocate(size_t w, size_t h, ofPixelFormat format){ } size_t newSize = w * h * pixelBitsFromPixelFormat(format); - size_t oldSize = size() * pixelBitsFromPixelFormat(pixelFormat); + size_t oldSize = width * height * pixelBitsFromPixelFormat(pixelFormat); //we check if we are already allocated at the right size if(bAllocated && newSize==oldSize){ pixelFormat = format; @@ -530,11 +532,11 @@ void ofPixels_::allocate(size_t w, size_t h, ofPixelFormat format){ width = w; height = h; - pixelsSize = w * h; + pixelsSize = w * h * getNumChannels(); // we have some incongruence here, if we use PixelType // we are not able to use RGB565 format - pixels = new PixelType[pixelsSize * getNumChannels()]; + pixels = new PixelType[pixelsSize]; // pixels = new uint8_t[newSize]; bAllocated = true; pixelsOwner = true; From c7d6cfc7baec6472b1c52df99c9ea1fe3ba5e383 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 28 Feb 2025 21:23:23 -0300 Subject: [PATCH 6/6] put back rgb565 only so it pass tests --- libs/openFrameworks/graphics/ofPixels.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/graphics/ofPixels.cpp b/libs/openFrameworks/graphics/ofPixels.cpp index 21074f24ae5..134b40ef8cf 100644 --- a/libs/openFrameworks/graphics/ofPixels.cpp +++ b/libs/openFrameworks/graphics/ofPixels.cpp @@ -144,8 +144,8 @@ static size_t channelsFromPixelFormat(ofPixelFormat format){ break; case OF_PIXELS_GRAY_ALPHA: - // this is not true for OF_PIXELS_RGB565. it has 3 channels and 2 bytes. - // case OF_PIXELS_RGB565: + // FIXME: this is not true for OF_PIXELS_RGB565. it has 3 channels and 2 bytes. + case OF_PIXELS_RGB565: return 2; break; case OF_PIXELS_NV12: