Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed flipy issue #8893

Merged
merged 4 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/PixelFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
38 changes: 38 additions & 0 deletions Specs/Core/PixelFormatSpec.js
Original file line number Diff line number Diff line change
@@ -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);
});
});