This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use anchor_lang::prelude::*; | |
// This is your program's public key and it will update | |
// automatically when you build the project. | |
declare_id!("ApNvFquHyG4kQTnAb3VAscw7URn3JDF6LYacsSzdxJqm"); | |
#[program] | |
pub mod rgb_color_setter { | |
// Imports | |
use anchor_lang::solana_program::{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func jpegDataFrom(image:NSImage) -> Data { | |
let cgImage = image.cgImage(forProposedRect: nil, context: nil, hints: nil)! | |
let bitmapRep = NSBitmapImageRep(cgImage: cgImage) | |
let jpegData = bitmapRep.representation(using: NSBitmapImageRep.FileType.jpeg, properties: [:])! | |
return jpegData | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func resizeImage(image:NSImage, maxSize:NSSize) -> NSImage { | |
var ratio:Float = 0.0 | |
let imageWidth = Float(image.size.width) | |
let imageHeight = Float(image.size.height) | |
let maxWidth = Float(maxSize.width) | |
let maxHeight = Float(maxSize.height) | |
// Get ratio (landscape or portrait) | |
if (imageWidth > imageHeight) { | |
// Landscape |