问题描述
- copyPixelsFromBuffer 结果图是原图尺寸的2倍,如何实现?
- 以下代码拿到的结果图尺寸与原图保持一致
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[] bgradataint 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( bgradataformat_in w_in h_in s_in bgradata format_out w_out h_out s_out zoomFactor2.0f1true); if (rst != ResultCode.CV_OK.getResultCode()) { throw new RuntimeException(""Calling cv_imagesdk_upscale method failed! ResultCode="" + rst); } }
时间: 2024-11-08 21:12:07