mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 04:54:04 -08:00
Refactor PlanarYUVLuminanceSource into core/
git-svn-id: https://zxing.googlecode.com/svn/trunk@2362 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
a7c40abe8f
commit
53ace36930
|
@ -16,9 +16,12 @@
|
|||
|
||||
package com.google.zxing.client.android;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.LuminanceSource;
|
||||
import com.google.zxing.MultiFormatReader;
|
||||
import com.google.zxing.PlanarYUVLuminanceSource;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.common.HybridBinarizer;
|
||||
|
@ -92,7 +95,8 @@ final class DecodeHandler extends Handler {
|
|||
if (handler != null) {
|
||||
Message message = Message.obtain(handler, R.id.decode_succeeded, rawResult);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());
|
||||
Bitmap grayscaleBitmap = toBitmap(source, source.renderCroppedGreyscaleBitmap());
|
||||
bundle.putParcelable(DecodeThread.BARCODE_BITMAP, grayscaleBitmap);
|
||||
message.setData(bundle);
|
||||
message.sendToTarget();
|
||||
}
|
||||
|
@ -104,4 +108,12 @@ final class DecodeHandler extends Handler {
|
|||
}
|
||||
}
|
||||
|
||||
private static Bitmap toBitmap(LuminanceSource source, int[] pixels) {
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import android.hardware.Camera;
|
|||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceHolder;
|
||||
import com.google.zxing.client.android.PlanarYUVLuminanceSource;
|
||||
import com.google.zxing.PlanarYUVLuminanceSource;
|
||||
import com.google.zxing.client.android.camera.open.OpenCameraManager;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -14,11 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.zxing.client.android;
|
||||
|
||||
import com.google.zxing.LuminanceSource;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
package com.google.zxing;
|
||||
|
||||
/**
|
||||
* This object extends LuminanceSource around an array of YUV data returned from the camera driver,
|
||||
|
@ -124,7 +120,7 @@ public final class PlanarYUVLuminanceSource extends LuminanceSource {
|
|||
false);
|
||||
}
|
||||
|
||||
public Bitmap renderCroppedGreyscaleBitmap() {
|
||||
public int[] renderCroppedGreyscaleBitmap() {
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
int[] pixels = new int[width * height];
|
||||
|
@ -139,10 +135,7 @@ public final class PlanarYUVLuminanceSource extends LuminanceSource {
|
|||
}
|
||||
inputOffset += dataWidth;
|
||||
}
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||
return bitmap;
|
||||
return pixels;
|
||||
}
|
||||
|
||||
private void reverseHorizontal(int width, int height) {
|
Loading…
Reference in a new issue