47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
use crate::{
|
|
commands::{wrap_command, wrap_origin_accessors},
|
|
macros::{wrap_fields, wrap_functions},
|
|
mem::{heap_move_nonnull, heap_remove},
|
|
};
|
|
use servicepoint::{Bitmap, BitmapCommand, CompressionCode, Origin};
|
|
use std::ptr::NonNull;
|
|
|
|
wrap_command!(Bitmap);
|
|
|
|
wrap_fields!(BitmapCommand;
|
|
prop bitmap: Bitmap { mut get(); move set(value); };
|
|
prop compression: CompressionCode { get(); set(value); };
|
|
);
|
|
|
|
wrap_origin_accessors!(BitmapCommand);
|
|
|
|
wrap_functions!(associate BitmapCommand;
|
|
/// Sets a window of pixels to the specified values.
|
|
///
|
|
/// The passed [Bitmap] gets consumed.
|
|
///
|
|
/// Returns: a new [BitmapCommand] instance.
|
|
fn new(
|
|
bitmap: NonNull<Bitmap>,
|
|
origin_x: usize,
|
|
origin_y: usize,
|
|
compression: CompressionCode,
|
|
) -> NonNull<BitmapCommand> {
|
|
heap_move_nonnull(BitmapCommand {
|
|
bitmap: unsafe { heap_remove(bitmap) },
|
|
origin: Origin::new(origin_x, origin_y),
|
|
compression,
|
|
})
|
|
}
|
|
|
|
/// Move the provided [Bitmap] into a new [BitmapCommand],
|
|
/// leaving other fields as their default values.
|
|
///
|
|
/// Rust equivalent: `BitmapCommand::from(bitmap)`
|
|
fn from_bitmap(
|
|
bitmap: NonNull<Bitmap>,
|
|
) -> NonNull<BitmapCommand> {
|
|
heap_move_nonnull(unsafe { heap_remove(bitmap) }.into())
|
|
}
|
|
);
|