以下代码拿到的结果图尺寸与原图保持一致
ByteBuffer mOutBuffer = ByteBuffer.allocate(width*2 * height*2 * 4);
mOutBuffer.rewind();
mBitmap.copyPixelsToBuffer(mOutBuffer);
upscale.upScale(mOutBuffer.array(), mBitmap.getWidth(), mBitmap.getHeight());
mOutBuffer.rewind();
mBitmap.copyPixelsFromBuffer(mOutBuffer);
public void upScale(byte[] bgradata,int width, int height)
{
float zoomFactor = 2.0f;
int format_in = CVImageFormat.CV_PIX_FMT_BGRA8888;
int w_in = width;
int h_in = height;
int s_in = w_in * 4;
int format_out = format_in;
int w_out = w_in * (int)zoomFactor;
int h_out = h_in * (int)zoomFactor;
int s_out = w_out * 4;
int rst = CvImageApiBridge.IMAGESDK_INSTANCE.cv_imagesdk_upscale(
bgradata,format_in, w_in, h_in, s_in,
bgradata, format_out, w_out, h_out, s_out,
zoomFactor,2.0f,1,true);
if (rst != ResultCode.CV_OK.getResultCode()) {
throw new RuntimeException("Calling cv_imagesdk_upscale method failed! ResultCode=" + rst);
}
}