鸿蒙开源三方组件(longimagecamera)--长图像拍摄器 原创 精华
mb60ffc171b51ba
发布于 2021-7-28 09:56
浏览
2收藏
1.介绍
LongImageCamera是通过相机视图,获取多个小图像来拼接成长图像的开源工具库。
该项目基于安卓平台的组件(https://github.com/wajahatkarim3/LongImageCamera )进行迁移和开发
2.效果展示
3.依赖
方法1:
(1). 下载源码并build longimagecamera_lib.har
(2). 在你的entry文件夹下的build.gradle按如下方式加载
dependencies {
implementation project(":longimagecamera_lib")
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
testImplementation 'junit:junit:4.13'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
}
方法2:
(1). 在工程的build.gradle的allprojects中,添加HAR所在的Maven仓地址
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}
(2). 在应用模块的build.gradle的dependencies闭包中,添加如下代码:
dependencies {
implementation 'io.github.dzsf:longimagecamera:1.0.1'
}
3 功能特性
(1).支持自动聚焦
public void setAutoFocus(boolean autoFocus){
if (mAutoFocus == autoFocus) {
return;
}
mAutoFocus = autoFocus;
if (mPreviewRequestBuilder != null) {
updateAutoFocus();
if (cameraDevice != null) {
try {
cameraDevice.stopLoopingCapture();
cameraDevice.triggerLoopingCapture(mPreviewRequestBuilder.build());
} catch (IllegalStateException e) {
mAutoFocus = !mAutoFocus;
}
}
}
}
(2).支持闪光灯切换
public void setFlash(int flash){
if (mFlash == flash) {
return;
}
int saved = mFlash;
mFlash = flash;
if (mPreviewRequestBuilder != null) {
updateFlash();
if (cameraDevice != null) {
try {
cameraDevice.stopLoopingCapture();
cameraDevice.triggerLoopingCapture(mPreviewRequestBuilder.build());
} catch (IllegalStateException e) {
mFlash = saved; // Revert
}
}
}
}
(3).支持最多5张图像拼接
private void prepareImageReader() {
Size largest = mPreviewSizes.sizes(mAspectRatio).last();
mImageReader = ImageReceiver.create(largest.getWidth(), largest.getHeight(),
ImageFormat.JPEG, /* maxImages */ MAX_IMAGE);
mImageReader.setImageArrivalListener(mOnImageAvailableListener);
}
(4).支持长图像放大、缩小、拖拽,滑动浏览
4 保存图片
图像转换为长图像后,会保存至图库中。
5 相关资料
项目地址:https://gitee.com/openneusoft/long-image-camera
IDE官方下载地址:https://developer.harmonyos.com/cn/develop/deveco-studio
©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
已于2021-7-28 10:04:34修改
赞
4
收藏 2
回复
相关推荐
感谢博主分享,已收藏