Skip to content

Instantly share code, notes, and snippets.

View Cronocide's full-sized avatar

Daniel Dayley Cronocide

View GitHub Profile
@zhangao0086
zhangao0086 / swift_hex.swift
Last active July 28, 2021 22:22
Convert image to hex. NSImage to byte array
// swift
var image = xxx
var rect = NSRect(x: 0, y: 0, width: image.size.width, height: image.size.height)
let cgImage = image.CGImageForProposedRect(&rect, context: nil, hints: nil)!.takeUnretainedValue()
let bitmapRep = NSBitmapImageRep(CGImage: cgImage)
if let imageData = bitmapRep.representationUsingType(NSBitmapImageFileType.NSPNGFileType, properties: [:]) {
let len = imageData.length
var bytes = [UInt8](count: len, repeatedValue: 0)
@jkhowland
jkhowland / Stack.h
Last active March 31, 2020 13:43
Simple Core Data - Stack.m
//
// Stack.m
//
// Created by Joshua Howland on 6/12/14.
// Copyright (c) 2014 DevMountain. All rights reserved.
//
#import <Foundation/Foundation.h>
@import CoreData;