Skip to content

Instantly share code, notes, and snippets.

View ralfebert's full-sized avatar

Ralf Ebert ralfebert

View GitHub Profile
@ralfebert
ralfebert / CompareImages.swift
Last active June 28, 2023 03:11 — forked from SheffieldKevin/compareimages.swift
A couple of swift functions for comparing two CGImage using CIImage in OS X
import CoreGraphics
import CoreImage
func imageMetadataString(image: CGImage) -> String {
return "\(image.width)x\(image.height) bitsPerComponent:\(image.bitsPerComponent) bytesPerRow:\(image.bytesPerRow) bitsPerPixel:\(image.bitsPerPixel)"
}
/**
@brief Returns the maximum difference of pixel values in the image.
@discussion Assumes doImagesHaveSameMeta has already returned true on
@ralfebert
ralfebert / swift-kvo-example.swift
Last active October 18, 2020 21:41 — forked from correia/swift-kvo-example.swift
Swift 1.1: dynamic for observable properties neccessary, observeValueForKeyPath signature changed
//
// Swift-KVO
//
// Created by Jim Correia on 6/5/14.
// Copyright (c) Jim Correia. All rights reserved.
//
// Update: 6/17/2014
//
// KVOContext has gone away; use the same idiom you'd use from Objective-C for the context