-
사진 흑백 컬러필터 및 적당히 잘라서 보여주기개발 2022. 4. 17. 00:20
완성 화면 1:흑백 필터 효과
https://api.flutter.dev/flutter/widgets/ColorFiltered-class.html
ColorFiltered class - widgets library - Dart API
Applies a ColorFilter to its child. This widget applies a function independently to each pixel of child's content, according to the ColorFilter specified. Use the ColorFilter.mode constructor to apply a Color using a BlendMode. Use the BackdropFilter widge
api.flutter.dev
ColorFiltered( colorFilter: ColorFilter.mode( Colors.black.withOpacity(0.55), BlendMode.darken), //withOpacity 높은 수록 검은색 진해짐 child: AspectRatio( //ratio 기능은 테스트 떄문에 넣어봄 없어도 됨 aspectRatio: 1, child: PhotoViewGallery.builder( // backgroundDecoration: // BoxDecoration(color: Colors.red), scrollPhysics: BouncingScrollPhysics(), builder: (BuildContext context, int index) { return PhotoViewGalleryPageOptions( disableGestures: true, imageProvider: FileImage( File(item.fileName), ), initialScale: PhotoViewComputedScale.contained * 1.9, ); }, itemCount: 1, ), )),
2. 사진 적당하게 자르기 (특히 왼쪽 오른쪽이 원본 사진보다 줄어서 보여주길 원함)
AspectRatio
해당 기능으로 구현을 했었지만 비율이 1:1 이 아닌 사진에서는 작동하지 않아서 고민해본 결과 확대 후 자르는 방식을 사용해서 구현 밑예 예시처럼 가로 비율이 세로보다 작은 사진은 올바르게 작동 하지 않음
에러 사항 밑에 라이브러리를 사용해서 적당한 비율로 확대해서 자연스럽게 잘라지는 효과를 사용함
https://pub.dev/packages/photo_view
photo_view | Flutter Package
Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interactive images and other stuff such as SVG.
pub.dev
3.완성된 화면
'개발' 카테고리의 다른 글
이미지 크기별로 캡쳐 방법론 (0) 2022.04.18 STICKER 구현 방법론 (0) 2022.04.18 지도 상점 정보 qr code 구현 (카카오 api+ 네이버 map) (0) 2022.03.17 slider bar custom(글씨 띄우기) (0) 2022.03.04 메인 화면 Tab Bar(한쪽면만 다르게 border 표현) (0) 2022.03.03