mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
pkg/macos: bitmap info arg
This commit is contained in:
@ -4,6 +4,7 @@ pub usingnamespace @import("graphics/bitmap_context.zig");
|
|||||||
pub usingnamespace @import("graphics/color_space.zig");
|
pub usingnamespace @import("graphics/color_space.zig");
|
||||||
pub usingnamespace @import("graphics/font.zig");
|
pub usingnamespace @import("graphics/font.zig");
|
||||||
pub usingnamespace @import("graphics/geometry.zig");
|
pub usingnamespace @import("graphics/geometry.zig");
|
||||||
|
pub usingnamespace @import("graphics/image.zig");
|
||||||
pub usingnamespace @import("graphics/path.zig");
|
pub usingnamespace @import("graphics/path.zig");
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
@ -15,6 +15,7 @@ pub const BitmapContext = opaque {
|
|||||||
bits_per_component: usize,
|
bits_per_component: usize,
|
||||||
bytes_per_row: usize,
|
bytes_per_row: usize,
|
||||||
space: *graphics.ColorSpace,
|
space: *graphics.ColorSpace,
|
||||||
|
opts: c_uint,
|
||||||
) Allocator.Error!*BitmapContext {
|
) Allocator.Error!*BitmapContext {
|
||||||
return @intToPtr(
|
return @intToPtr(
|
||||||
?*BitmapContext,
|
?*BitmapContext,
|
||||||
@ -25,7 +26,7 @@ pub const BitmapContext = opaque {
|
|||||||
bits_per_component,
|
bits_per_component,
|
||||||
bytes_per_row,
|
bytes_per_row,
|
||||||
@ptrCast(c.CGColorSpaceRef, space),
|
@ptrCast(c.CGColorSpaceRef, space),
|
||||||
0,
|
opts,
|
||||||
)),
|
)),
|
||||||
) orelse Allocator.Error.OutOfMemory;
|
) orelse Allocator.Error.OutOfMemory;
|
||||||
}
|
}
|
||||||
@ -36,7 +37,7 @@ test {
|
|||||||
|
|
||||||
const cs = try graphics.ColorSpace.createDeviceGray();
|
const cs = try graphics.ColorSpace.createDeviceGray();
|
||||||
defer cs.release();
|
defer cs.release();
|
||||||
const ctx = try BitmapContext.create(null, 80, 80, 8, 80, cs);
|
const ctx = try BitmapContext.create(null, 80, 80, 8, 80, cs, 0);
|
||||||
defer ctx.release();
|
defer ctx.release();
|
||||||
|
|
||||||
ctx.setShouldAntialias(true);
|
ctx.setShouldAntialias(true);
|
||||||
|
@ -49,7 +49,7 @@ pub fn Context(comptime T: type) type {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setRGBFillColor(self: *T, r: f64, g: f64, b: 64, alpha: f64) void {
|
pub fn setRGBFillColor(self: *T, r: f64, g: f64, b: f64, alpha: f64) void {
|
||||||
c.CGContextSetRGBFillColor(
|
c.CGContextSetRGBFillColor(
|
||||||
@ptrCast(c.CGContextRef, self),
|
@ptrCast(c.CGContextRef, self),
|
||||||
r,
|
r,
|
||||||
@ -80,6 +80,13 @@ pub fn Context(comptime T: type) type {
|
|||||||
y,
|
y,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fillRect(self: *T, rect: graphics.Rect) void {
|
||||||
|
c.CGContextFillRect(
|
||||||
|
@ptrCast(c.CGContextRef, self),
|
||||||
|
@bitCast(c.CGRect, rect),
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
31
pkg/macos/graphics/image.zig
Normal file
31
pkg/macos/graphics/image.zig
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const assert = std.debug.assert;
|
||||||
|
const Allocator = std.mem.Allocator;
|
||||||
|
const graphics = @import("../graphics.zig");
|
||||||
|
const context = @import("context.zig");
|
||||||
|
const c = @import("c.zig");
|
||||||
|
|
||||||
|
pub const ImageAlphaInfo = enum(c_uint) {
|
||||||
|
none = c.kCGImageAlphaNone,
|
||||||
|
premultiplied_last = c.kCGImageAlphaPremultipliedLast,
|
||||||
|
premultiplied_first = c.kCGImageAlphaPremultipliedFirst,
|
||||||
|
last = c.kCGImageAlphaLast,
|
||||||
|
first = c.kCGImageAlphaFirst,
|
||||||
|
none_skip_last = c.kCGImageAlphaNoneSkipLast,
|
||||||
|
none_skip_first = c.kCGImageAlphaNoneSkipFirst,
|
||||||
|
only = c.kCGImageAlphaOnly,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const BitmapInfo = enum(c_uint) {
|
||||||
|
alpha_mask = c.kCGBitmapAlphaInfoMask,
|
||||||
|
float_mask = c.kCGBitmapFloatInfoMask,
|
||||||
|
float_components = c.kCGBitmapFloatComponents,
|
||||||
|
byte_order_mask = c.kCGBitmapByteOrderMask,
|
||||||
|
byte_order_default = c.kCGBitmapByteOrderDefault,
|
||||||
|
byte_order_16_little = c.kCGBitmapByteOrder16Little,
|
||||||
|
byte_order_32_little = c.kCGBitmapByteOrder32Little,
|
||||||
|
byte_order_16_big = c.kCGBitmapByteOrder16Big,
|
||||||
|
byte_order_32_big = c.kCGBitmapByteOrder32Big,
|
||||||
|
|
||||||
|
_,
|
||||||
|
};
|
@ -193,7 +193,7 @@ test {
|
|||||||
{
|
{
|
||||||
const cs = try graphics.ColorSpace.createDeviceGray();
|
const cs = try graphics.ColorSpace.createDeviceGray();
|
||||||
defer cs.release();
|
defer cs.release();
|
||||||
const ctx = try graphics.BitmapContext.create(null, 80, 80, 8, 80, cs);
|
const ctx = try graphics.BitmapContext.create(null, 80, 80, 8, 80, cs, 0);
|
||||||
defer ctx.release();
|
defer ctx.release();
|
||||||
|
|
||||||
var pos = [_]graphics.Point{.{ .x = 0, .y = 0 }};
|
var pos = [_]graphics.Point{.{ .x = 0, .y = 0 }};
|
||||||
|
Reference in New Issue
Block a user