Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
fix Pixa.replacePix()
Browse files Browse the repository at this point in the history
fix JavaDoc
enable and fix testPixaReplacePix

see #159 (comment)
  • Loading branch information
alexcohn committed Jul 18, 2019
1 parent 8a400c4 commit 193d072
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,38 +146,36 @@ private void internalTestPixaJoin(int sizeA, int sizeB) {
pixaB.recycle();
}

// @SmallTest
// public void testPixaReplacePix() {
// Pixa pixa = Pixa.createPixa(0, 640, 480);
//
// // Populate the Pixa.
// addBlockToPixa(pixa, 0, 0, 640, 480, 8);
//
// Pix pix = new Pix(320, 240, 8);
// Box box = new Box(320, 240, 320, 240);
//
// // Replace the existing Pix.
// pixa.replacePix(0, pix, box);
//
// // Ensure the replacement was successful.
// Pix returnedPix = pixa.getPix(0);
// Box returnedBox = pixa.getBox(0);
//
// assertEquals(pix.getWidth(), returnedPix.getWidth());
// assertEquals(pix.getHeight(), returnedPix.getHeight());
// assertEquals(pix.getDepth(), returnedPix.getDepth());
//
// assertEquals(box.getX(), returnedBox.getX());
// assertEquals(box.getY(), returnedBox.getY());
// assertEquals(box.getWidth(), returnedBox.getWidth());
// assertEquals(box.getHeight(), returnedBox.getHeight());
//
// pix.recycle();
// box.recycle();
// returnedPix.recycle();
// returnedBox.recycle();
// pixa.recycle();
// }
@SmallTest
public void testPixaReplacePix() {
Pixa pixa = Pixa.createPixa(0, 640, 480);

// Populate the Pixa.
addBlockToPixa(pixa, 0, 0, 640, 480, 8);

Pix pix = new Pix(320, 240, 8);
Box box = new Box(320, 240, 320, 240);

// Replace the existing Pix.
pixa.replacePix(0, pix, box);

// Ensure the replacement was successful.
Pix returnedPix = pixa.getPix(0);
Box returnedBox = pixa.getBox(0);

assertEquals(pix.getWidth(), returnedPix.getWidth());
assertEquals(pix.getHeight(), returnedPix.getHeight());
assertEquals(pix.getDepth(), returnedPix.getDepth());

assertEquals(box.getX(), returnedBox.getX());
assertEquals(box.getY(), returnedBox.getY());
assertEquals(box.getWidth(), returnedBox.getWidth());
assertEquals(box.getHeight(), returnedBox.getHeight());

returnedPix.recycle();
returnedBox.recycle();
pixa.recycle();
}

@SmallTest
public void testPixaMergeAndReplacePix() {
Expand Down
6 changes: 3 additions & 3 deletions tess-two/src/com/googlecode/leptonica/android/Pixa.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,11 @@ public ArrayList<Rect> getBoxRects() {

/**
* Replaces the Pix and Box at the specified index with the specified Pix
* and Box, both of which may be recycled after calling this method.
* and Box, both of which should not be recycled after calling this method.
*
* @param index The index of the Pix to replace.
* @param pix The Pix to replace the existing Pix.
* @param box The Box to replace the existing Box.
* @param pix The Pix to replace the existing Pix; it becomes an alias of the one stored in Pixa.
* @param box The Box to replace the existing Box; it becomes an alias of the one stored in Pixa.
*/
public void replacePix(int index, Pix pix, Box box) {
if (mRecycled)
Expand Down

0 comments on commit 193d072

Please sign in to comment.