forked from devilsen/CZXing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
106 additions
and
34 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
czxing/src/main/java/me/devilsen/czxing/util/ResolutionAdapterUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package me.devilsen.czxing.util; | ||
|
||
/** | ||
* desc : 分辨率转换util | ||
* date : 2019-08-20 17:07 | ||
* | ||
* @author : dongSen | ||
*/ | ||
public class ResolutionAdapterUtil { | ||
|
||
private int resolutionWidth; | ||
private int resolutionHeight; | ||
|
||
private int cameraWidth; | ||
private int cameraHeight; | ||
|
||
private float ratioWidth; | ||
private float ratioHeight; | ||
|
||
public void setResolutionSize(int resolutionWidth, int resolutionHeight) { | ||
this.resolutionWidth = resolutionWidth; | ||
this.resolutionHeight = resolutionHeight; | ||
setRatio(); | ||
} | ||
|
||
public void setCameraSize(int cameraWidth, int cameraHeight) { | ||
this.cameraWidth = cameraWidth; | ||
this.cameraHeight = cameraHeight; | ||
if (cameraWidth > cameraHeight) { | ||
int temp = this.cameraWidth; | ||
this.cameraWidth = this.cameraHeight; | ||
this.cameraHeight = temp; | ||
} | ||
setRatio(); | ||
} | ||
|
||
private void setRatio() { | ||
if (ratioWidth == 0 && resolutionWidth != 0 && cameraWidth != 0) { | ||
ratioWidth = 1.0f * cameraWidth / resolutionWidth; | ||
} | ||
if (ratioHeight == 0 && resolutionHeight != 0 && cameraHeight != 0) { | ||
ratioHeight = 1.0f * cameraHeight / resolutionHeight; | ||
} | ||
} | ||
|
||
public int getAdapterWidth(int width) { | ||
if (ratioWidth != 0) { | ||
return (int) (ratioWidth * width); | ||
} | ||
return width; | ||
} | ||
|
||
public int getAdapterHeight(int height) { | ||
if (ratioHeight != 0) { | ||
return (int) (ratioHeight * height); | ||
} | ||
return height; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters