Git Product home page Git Product logo

androidstudioist / sketch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from panpf/sketch

0.0 0.0 0.0 256.53 MB

Sketch 是 Android 上的一个强大且全面的图片加载库,除了基础功能外,还支持 GIF、SVG,手势缩放、分块显示超大图片、ExifInterface、视频缩略图、Jetpack Compose 等功能。Sketch is a powerful and comprehensive image load library on Android, in addition to the basic functions, it also supports GIF, SVG, gesture zoom, block display of huge images, ExifInterface, video thumbnails, Jetpack Compose and other functions

License: Apache License 2.0

Java 5.78% Kotlin 94.22%

sketch's Introduction

logo_image Sketch Image Loader

Platform API License version_icon QQ Group

Sketch 是 Android 上的一个强大且全面的图片加载库,除了基础功能外,还支持 GIF、SVG,手势缩放、分块显示超大图片、ExifInterface、视频缩略图、Jetpack Compose 等功能

关于 3.0 版本

  • maven groupId 改为 io.github.panpf.sketch3,因此 2.* 版本不会提示升级
  • 包名改为 com.github.panpf.sketch 因此与 2.* 版本不会冲突
  • 基于 kotlin 协程重写,API、功能实现全部改变,当一个新的库用就行
  • 参考 coil 2.0.0-alpha05 版本并结合 sketch 原有功能实现,coil 最低支持 API 21,而 sketch 最低支持 API 16

简介

  • 支持 http、asset、content、android.resource 等多种 URI
  • 支持播放 gif、webp、heif 等动图
  • 支持手势缩放及分块显示超大图片
  • 支持下载、转换结果、内存三级缓存
  • 支持通过 Exif 纠正图片方向
  • 支持 Base64、视频帧、SVG 图片
  • 支持 Jetpack Compose
  • 支持根据 view 大小自动调整图片尺寸
  • 支持仅加载图片到内存或仅下载图片到磁盘
  • 支持节省蜂窝流量等各种实用功能
  • 支持对 URI、缓存、解码、转换、显示、占位图等各个环节的扩展
  • 基于 Kotlin 及 Kotlin 协程编写

导入

已发布到 mavenCentral

dependencies {
    implementation("io.github.panpf.sketch3:sketch:${LAST_VERSION}")
}

${LAST_VERSION}: Download (不包含 'v')

还有一些可选的模块用来扩展 sketch 的功能:

dependencies {
    // 支持 Jetpack Compose
    implementation("io.github.panpf.sketch3:sketch-compose:${LAST_VERSION}")

    // 支持下载进度蒙层、列表滑动中暂停加载、节省蜂窝流量、图片类型角标、加载 apk 文件和已安装 app 图标等实用功能
    implementation("io.github.panpf.sketch3:sketch-extensions:${LAST_VERSION}")

    // 通过 koral 的 android-gif-drawable 库的 GifDrawable 实现 gif 播放
    implementation("io.github.panpf.sketch3:sketch-gif-koral:${LAST_VERSION}")

    // 通过 Android 内置的 Movie 类实现 gif 播放
    implementation("io.github.panpf.sketch3:sketch-gif-movie:${LAST_VERSION}")

    // 支持 OkHttp
    implementation("io.github.panpf.sketch3:sketch-okhttp:${LAST_VERSION}")

    // 支持 SVG 图片
    implementation("io.github.panpf.sketch3:sketch-svg:${LAST_VERSION}")

    // 通过 Android 内置的 MediaMetadataRetriever 类实现读取视频帧
    implementation("io.github.panpf.sketch3:sketch-video:${LAST_VERSION}")

    // 通过 wseemann 的 FFmpegMediaMetadataRetriever 库实现读取视频帧
    implementation("io.github.panpf.sketch3:sketch-video-ffmpeg:${LAST_VERSION}")

    // 支持手势缩放以及分块显示超大图片
    implementation("io.github.panpf.sketch3:sketch-zoom:${LAST_VERSION}")
}

R8 / Proguard

sketch 自己不需要配置任何混淆规则,但你可能需要为间接依赖的 Kotlin Coroutines, OkHttp, Okio 添加混淆配置

快速上手

ImageView

// http
imageView.displayImage("https://www.sample.com/image.jpg")

// File
imageView.displayImage("/sdcard/download/image.jpg")

// asset
imageView.displayImage("asset://image.jpg")

// There is a lot more...

还可以通过尾随的 lambda 函数配置参数:

imageView.displayImage("https://www.sample.com/image.jpg") {
    placeholder(R.drawable.placeholder)
    error(R.drawable.error)
    transformations(CircleCropTransformation())
    crossfade()
    // There is a lot more...
}

Jetpack Compose

需要先导入 sketch-compose 模块

AsyncImage(
    imageUri = "https://www.sample.com/image.jpg",
    modifier = Modifier.size(300.dp, 200.dp),
    contentScale = ContentScale.Crop,
    contentDescription = ""
) {
    placeholder(R.drawable.placeholder)
    error(R.drawable.error)
    transformations(CircleCropTransformation())
    crossfade()
    // There is a lot more...
}

文档

基础功能:

特色功能:

更新日志

请查看 CHANGELOG.md 文件

特别感谢

License

Copyright (C) 2019 panpf <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

sketch's People

Contributors

panpf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.