Generates an image that looks like LEGO Art.

Related tags

Image LegoArtFilter
Overview

LegoArtFilter

Generates an image that looks like LEGO Art.
This library supports both iOS (14≤) and macOS (11≤).

Usage

// Get CGImage from CIImage
let input = CIImage()
if let legoArt = LegoArt(ciImage: input) {
    let output = legoArt.exportCGImage()
}

// Get UIImage from UIImage
let input = UIImage()
if let legoArt = LegoArt(from: input) {
    let output = legoArt.exportUIImage()
}

// Get NSImage from NSImage
let input = NSImage()
if let legoArt = LegoArt(from: input) {
    let output = legoArt.exportNSImage()
}

// Use the options
// baseColor:      It is used as a base for transparent images such as PNG.
// StudType:       It is reflected in the appearance of the brick.
//                 (round/round plate/square/square plate)
// maxStud:        Determines the maximum bricks number of the generated image.
// studPixelWidth: Specifies the pixel width of the actual brick to be drawn.
let legoArt = LegoArt(ciImage: CIImage,
                      baseColor: CGColor,
                      studType: StudType,
                      maxStud: Int,
                      studPixelWidth: Int)

LICENSE

Copyright (c) 2021 Takuto NAKAMURA (Kyome)

You are free to use it as long as it is not for commercial use.

You might also like...
Convert the image to hexadecimal to send the image to e-paper

ConvertImageToHex Convert the image to hexadecimal to send the image to e-paper Conversion Order // 0. hex로 변환할 이미지 var image = UIImage(named: "sample

Twitter Image Pipeline is a robust and performant image loading and caching framework for iOS clients

Twitter Image Pipeline (a.k.a. TIP) Background The Twitter Image Pipeline is a streamlined framework for fetching and storing images in an application

Image-cropper - Image cropper for iOS

Image-cropper Example To run the example project, clone the repo, and run pod in

Image filtering UI library like Instagram.
Image filtering UI library like Instagram.

Sharaku Usage How to present SHViewController let imageToBeFiltered = UIImage(named: "targetImage") let vc = SHViewController(image: imageToBeFiltered

📸 Instagram-like image picker & filters for iOS
📸 Instagram-like image picker & filters for iOS

YPImagePicker YPImagePicker is an instagram-like photo/video picker for iOS written in pure Swift. It is feature-rich and highly customizable to match

ZImageCropper is a simplest way to crop image to any shapes you like.
ZImageCropper is a simplest way to crop image to any shapes you like.

ZImageCropper ZImageCropper is a simplest way to crop image to any shapes you like. Example To run the example project, clone the repo, and run pod in

📸 iMessage-like, Image Picker Controller Provides custom features.

RAImagePicker Description RAImagePicker is a protocol-oriented framework that provides custom features from the built-in Image Picker Edit. Overview O

An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.
An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.

RSKImageCropper An image cropper for iOS like in the Contacts app with support for landscape orientation. Installation RSKImageCropper requires iOS 9.

Simple UIView to interact with an Image view like scroll, zoom, pinch and crop.
Simple UIView to interact with an Image view like scroll, zoom, pinch and crop.

Welcome to Interactive Image View, a simple library that provides an easier way to interact with image view, like scroll, zoom and crop. In its core i

Comments
  • Improve performance

    Improve performance

    概要

    LegoColor(r:g:b:) の処理に時間がかかるため、rgb の値をキーとしてキャッシュするようにしました。

    私のアイコンを StudType: RoundMax Stud: 128 で試したところ、処理時間が約 1/33 になりました。 同じ色を使っている画像ほど処理が速くなります。 逆にほぼ異なる色だと、キャッシュを捜査する分だけ処理が遅くなりますが、具体的な時間は計測していません。

    処理時間の計測は colorMap 生成の前後に以下を仕込んで行いました。

    +       let startDate = Date()
            let colorMap = (0 ..< Int(size.width * size.height))
                .map { i -> LegoColor in
                    let r = CGFloat(rgbaData[4 * i]) / 255.0
                    let g = CGFloat(rgbaData[4 * i + 1]) / 255.0
                    let b = CGFloat(rgbaData[4 * i + 2]) / 255.0
                    return LegoColor(r: r, g: g, b: b)
                }
    +       print("Time: \(Date().timeIntervalSince(startDate))")
    

    Before

    |Time| |:--| |2.201616048812866| |2.205173969268799| |2.2091729640960693| |2.2038110494613647| |2.204527974128723|

    After

    |time| |:--| |0.06664800643920898| |0.06678497791290283| |0.06787693500518799| |0.06665492057800293| |0.06649196147918701|

    スクリーンショット 2021-10-18 20 35 40
    opened by uhooi 3
  • Add examples

    Add examples

    概要

    デモは同じリポジトリにあるほうがわかりやすいため、 LegoArtFilterDemo の内容を Examples フォルダに追加しました。 ライブラリをローカル参照するように変更したため、デモを開発環境として使うこともできます。

    参考リンク

    • https://speakerdeck.com/uhooi/create-swift-library
    • https://speakerdeck.com/niw/shi-jian-ios-opunsosupuroziekutofalseshi-mefang
    opened by uhooi 2
Releases(1.0.0)
Owner
Takuto NAKAMURA (Kyome)
macOS, iOS, Android developer. Swift / Objective-C / Javascript / Java / Python / C / C++ / C#
Takuto NAKAMURA (Kyome)
Convert UIImage to ASCII art

BKAsciiImage As seen on Cmd.fm iOS App https://itunes.apple.com/app/cmd.fm-radio-for-geeks-hackers/id935765356 Installation BKAsciiImage is available

Barış Koç 427 Dec 17, 2022
An instagram-like image editor that can apply preset filters passed to it and customized editings to a binded image.

CZImageEditor CZImageEditor is an instagram-like image editor with clean and intuitive UI. It is pure swift and can apply preset filters and customize

null 8 Dec 16, 2022
📦 An extension that generates letter-based avatars/placeholders

LetterAvatarKit LetterAvatarKit provides an UIImage extension for generating letter-based avatars/placeholders. There are a few images showing what yo

Victor Peschenkov 215 Dec 21, 2022
App that generates random images and attempts to classify them with MobileNetV2

Image-Classifier-App App that generates random images and attempts to classify t

Eli Hartnett 0 Jul 9, 2022
📷 A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component ?? v2.0.0-alpha now open!

Muukii 2.8k Jan 3, 2023
An image download extension of the image view written in Swift for iOS, tvOS and macOS.

Moa, an image downloader written in Swift for iOS, tvOS and macOS Moa is an image download library written in Swift. It allows to download and show an

Evgenii Neumerzhitckii 330 Sep 9, 2022
📷 A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component ?? v2.0.0-alpha now open!

Muukii 2.8k Jan 2, 2023
AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.

URLImage URLImage is a SwiftUI view that displays an image downloaded from provided URL. URLImage manages downloading remote image and caching it loca

Dmytro Anokhin 1k Jan 4, 2023
AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.

AYImageKit AYImageKit is a Swift Library for Async Image Downloading. Features Async Image Downloading. Can Show Text Initials. Can have Custom Styles

Adnan Yousaf 11 Jan 10, 2022
A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image.

QRDecode A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image. QRDecode

David Phillip Oster 2 Oct 28, 2022