From 43362d91c5c5b5914fd7eca084c87fc383432773 Mon Sep 17 00:00:00 2001 From: Eli Bogomolny Date: Mon, 1 Jun 2020 11:18:48 -0400 Subject: [PATCH 1/4] fixed flipy issue --- Source/Core/PixelFormat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/PixelFormat.js b/Source/Core/PixelFormat.js index 241dbd2569da..fd603e08fcbf 100644 --- a/Source/Core/PixelFormat.js +++ b/Source/Core/PixelFormat.js @@ -360,8 +360,8 @@ PixelFormat.flipY = function ( var numberOfComponents = PixelFormat.componentsLength(pixelFormat); var textureWidth = width * numberOfComponents; for (var i = 0; i < height; ++i) { - var row = i * height * numberOfComponents; - var flippedRow = (height - i - 1) * height * numberOfComponents; + var row = i * width * numberOfComponents; + var flippedRow = (height - i - 1) * width * numberOfComponents; for (var j = 0; j < textureWidth; ++j) { flipped[flippedRow + j] = bufferView[row + j]; } From bc901aeaf6d91521b54f6a3291919392f3e8a76c Mon Sep 17 00:00:00 2001 From: Eli Bogomolny Date: Mon, 1 Jun 2020 11:37:15 -0400 Subject: [PATCH 2/4] updated CHANGES.md --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index abecf42c8e6b..540fcf94b0d7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Change Log +### 1.71.0 - 2020-07-01 + +##### Fixes :wrench: + +- Fixed a bug with handling of PixelFormat's flipY. [#8893](https://github.com/CesiumGS/cesium/pull/8893) + ### 1.70.0 - 2020-06-01 ##### Major Announcements :loudspeaker: From 6e59c2a03be98980db0c27789d43df8c63c38a4b Mon Sep 17 00:00:00 2001 From: Eli Bogomolny Date: Mon, 1 Jun 2020 11:44:17 -0400 Subject: [PATCH 3/4] added myself to CONTRIBUTORS.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4d66e4d786bb..c4b84356a460 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -143,6 +143,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu - [Samuel Vargas](https://github.com/Samulus) - [Sam Suhag](https://github.com/sanjeetsuhag) - [Youssef Victor](https://github.com/YoussefV) + - [Eli Bogomolny](https://github.com/ebogo1) - [Northrop Grumman](http://www.northropgrumman.com) - [Joseph Stein](https://github.com/nahgrin) - [EOX IT Services GmbH](https://eox.at) From a3d8e3ed5441002406c9a673d4df33294731de3a Mon Sep 17 00:00:00 2001 From: Eli Bogomolny Date: Mon, 1 Jun 2020 12:05:19 -0400 Subject: [PATCH 4/4] added tests for flipY function --- Specs/Core/PixelFormatSpec.js | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Specs/Core/PixelFormatSpec.js diff --git a/Specs/Core/PixelFormatSpec.js b/Specs/Core/PixelFormatSpec.js new file mode 100644 index 000000000000..1c9e7ebb0c51 --- /dev/null +++ b/Specs/Core/PixelFormatSpec.js @@ -0,0 +1,38 @@ +import { PixelDatatype } from "../../Source/Cesium.js"; +import { PixelFormat } from "../../Source/Cesium.js"; + +describe("Core/PixelFormat", function () { + it("flipY works", function () { + var width = 1; + var height = 2; + var values = [255, 0, 0, 0, 255, 0]; + var expectedValues = [0, 255, 0, 255, 0, 0]; + var dataBuffer = new Uint8Array(values); + var expectedDataBuffer = new Uint8Array(expectedValues); + + var flipped = PixelFormat.flipY( + dataBuffer, + PixelFormat.RGB, + PixelDatatype.UNSIGNED_BYTE, + width, + height + ); + expect(flipped).toEqual(expectedDataBuffer); + }); + + it("flipY returns early if height is 1", function () { + var width = 1; + var height = 1; + var values = [255, 255, 255]; + var dataBuffer = new Uint8Array(values); + + var flipped = PixelFormat.flipY( + dataBuffer, + PixelFormat.RGB, + PixelDatatype.UNSIGNED_BYTE, + width, + height + ); + expect(flipped).toBe(dataBuffer); + }); +});