image_pixels 패키지는 개발자가 이미지의 배경 색상을 확장하거나 이미지 크기와 픽셀 색상에 의존하는 위젯을 생성할 수 있도록 합니다. 이 패키지는 픽셀 단위에서 이미지를 분석하고 조작할 수 있는 도구를 제공하여 사용자 정의 시각 효과, 동적 배경 및 이미지 콘텐츠 기반 반응형 UI에 적합합니다. Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼을 지원하며 광범위한 호환성을 보장합니다. 성능과 간편함에 중점을 두어 pub.dev를 통해 Flutter 프로젝트에 원활하게 통합됩니다.
사용 사례
동적 배경색 확장
이미지 크기에 따라 위젯 만들기
픽셀 수준의 이미지 분석
이미지 데이터를 갖춘 반응형 UI
사용자 지정 시각 효과
이미지 기반 레이아웃 조정
주요 기능
이미지의 배경 색상 확장
픽셀 색상 분석
이미지 너비/높이 종속성 지원
크로스 플랫폼 호환성
경량이고 효율적
Flutter와의 간편한 통합
적합한 대상
이미지 기반 UI를 구축하는 개발자
픽셀 단위 정밀 레이아웃이 필요한 디자이너
동적 이미지 배경이 필요한 앱
반응형 이미지 컴포넌트를 갖춘 프로젝트
다중 플랫폼을 대상으로 하는 Flutter 앱
고려 사항
픽셀 분석 전 이미지 로드 필요
큰 이미지의 성능 영향
정적 이미지 처리에 제한됨
실시간 비디오에 적합하지 않습니다
사전 로드된 이미지와 함께 사용하는 것이 가장 좋습니다
반복 사용을 위해 추가 캐싱이 필요할 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Sponsor
image_pixels
This package allows you to build a widget that depends on, or uses the values of:
The ImagePixels constructor lets you define an image through an imageProvider, and
then use a builder to build a child widget that depends on the image dimensions and the
color of its pixels.
The default constructor lets you provide the imageProvider, the builder, as well as
a defaultColor to be used when reading pixels outside the image bounds or while the
image is still downloading.
For example, this will display the size of the image as a Text widget:
The builder function gives you access to an img parameter of type ImgDetails, with
the following information:
If the image is already available, img.hasImage is true, and img.width
and img.height indicate the image dimensions.
While the image is not yet available,
img.hasImage is false, and img.width and img.height are null.
The functions img.pixelColorAt() and img.pixelColorAtAlignment()
can be used in the builder body to read the color of the image pixels.
If the coordinates point to outside the image, or if the image is not yet available (is
still being downloaded or failed to download), then these functions will return
the defaultColor provided in the ImagePixels constructor.
The img.uiImage parameter contains the image as a ui.Image type. It will be null
while the image is still downloading.
The img.byteData parameter contains the image as a ByteData type. It will be null
while the image is still downloading.
Other use cases
Getting the tapped pixel color: By wrapping the child of the ImagePixel with
a GestureDetector you can obtain the x/y position where the user tapped the image.
From this information, you can then determine the color of the tapped pixel.
Try running
the
Example.
Modifying the image: The child of the ImagePixel can be a CustomPainter. Then,
you can use a canvas to paint whatever you want on top of the image, or else create
an entirely new image from the pixels of the original image.