Skip to content

Commit 8be3280

Browse files
rename storage to pixels and fix some documentation
1 parent 2a641f0 commit 8be3280

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

examples/1_rgb_exr_to_png.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn main() {
4646
};
4747

4848
// save the png buffer to a png file
49-
let png_buffer = &image.layer_data.channel_data.storage;
49+
let png_buffer = &image.layer_data.channel_data.pixels;
5050
png_buffer.save("tests/images/out/rgb.png").unwrap();
5151
println!("created image rgb.png")
5252
}

examples/2_rgba_exposure_adjust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn main() {
4545
let exposure_multiplier = 2.0;
4646

4747
{ // increase exposure of all pixels
48-
for line in &mut image.layer_data.channel_data.storage.lines {
48+
for line in &mut image.layer_data.channel_data.pixels.lines {
4949
for (r,g,b,_) in line {
5050
// you should probably check the color space and white points
5151
// for high quality color adjustments

examples/4_specific_read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn main() {
3838

3939
// output a random color of each channel of each layer
4040
for layer in &image.layer_data {
41-
let (alpha, luma, luma_right) = layer.channel_data.storage.first().unwrap().first().unwrap();
41+
let (alpha, luma, luma_right) = layer.channel_data.pixels.first().unwrap().first().unwrap();
4242

4343
println!(
4444
"bottom left color of layer `{}`: (a, y, yr) = {:?}",

src/image/crop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<'c, Channels> ChannelsWriter for CroppedWriter<Channels> where Channels: Ch
200200
impl<Samples, Channels> InspectSample for Layer<SpecificChannels<Samples, Channels>> where Samples: GetPixel {
201201
type Sample = Samples::Pixel;
202202
fn inspect_sample(&self, local_index: Vec2<usize>) -> Samples::Pixel {
203-
self.channel_data.storage.get_pixel(local_index)
203+
self.channel_data.pixels.get_pixel(local_index)
204204
}
205205
}
206206

src/image/mod.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ pub struct Image<Layers> {
8080
pub layer_data: Layers,
8181
}
8282

83-
/// A list of layers. `Channels` can be `RgbaChannels` or `AnyChannels`.
83+
/// A list of layers. `Channels` can be `SpecificChannels` or `AnyChannels`.
8484
pub type Layers<Channels> = SmallVec<[Layer<Channels>; 2]>;
8585

8686
/// A single Layer, including fancy attributes and compression settings.
87-
/// `Channels` can be either `RgbaChannels` or `AnyChannels`
87+
/// `Channels` can be either `SpecificChannels` or `AnyChannels`
8888
#[derive(Debug, Clone, PartialEq)]
8989
pub struct Layer<Channels> {
9090

91-
/// The actual pixel data. Either `RgbaChannels` or `AnyChannels`
91+
/// The actual pixel data. Either `SpecificChannels` or `AnyChannels`
9292
pub channel_data: Channels,
9393

9494
/// Attributes that apply to this layer.
@@ -142,23 +142,23 @@ pub enum Blocks {
142142
}
143143

144144

145-
/// A grid of rgba pixels. The pixels are written to your custom pixel storage.
145+
/// A grid of pixels. The pixels are written to your custom pixel storage.
146146
/// `PixelStorage` can be anything, from a flat `Vec<f16>` to `Vec<Vec<AnySample>>`, as desired.
147-
/// In order to write this image to a file, your `PixelStorage` must implement [`GetRgbaPixel`].
147+
/// In order to write this image to a file, your `PixelStorage` must implement [`GetPixel`].
148148
#[derive(Debug, Clone, PartialEq, Eq)]
149-
pub struct SpecificChannels<PixelStorage, ChannelsDescription> {
149+
pub struct SpecificChannels<Pixels, ChannelsDescription> {
150150

151151
/// A description of the channels in the file, as opposed to the channels in memory.
152152
/// Should always be a tuple containing `ChannelDescription`s, one description for each channel.
153153
pub channels: ChannelsDescription, // TODO this is awkward. can this be not a type parameter please? maybe vec<option<chan_info>> ??
154154

155-
/// Your custom rgba pixel storage
156-
// TODO should also support `Levels<YourStorage>`, where rgba levels are desired!
157-
pub storage: PixelStorage, // TODO rename to "pixels"?
155+
/// Your custom pixel storage
156+
// TODO should also support `Levels<YourStorage>`, where levels are desired!
157+
pub pixels: Pixels, // TODO rename to "pixels"?
158158
}
159159

160160

161-
/// A full list of arbitrary channels, not just rgba.
161+
/// A dynamic list of arbitrary channels.
162162
/// `Samples` can currently only be `FlatSamples` or `Levels<FlatSamples>`.
163163
#[derive(Debug, Clone, PartialEq)]
164164
pub struct AnyChannels<Samples> {
@@ -257,7 +257,7 @@ pub enum DeepAndFlatSamples {
257257
///
258258
/// Since this is close to the pixel layout in the byte file,
259259
/// this will most likely be the fastest storage.
260-
/// Using a different storage, for example `RgbaChannels`,
260+
/// Using a different storage, for example `SpecificChannels`,
261261
/// will probably be slower.
262262
#[derive(Clone, PartialEq)] // debug is implemented manually
263263
pub enum FlatSamples {
@@ -313,7 +313,7 @@ impl<SampleStorage, Channels> SpecificChannels<SampleStorage, Channels> {
313313
Channels: Sync + Clone + IntoRecursive,
314314
<Channels as IntoRecursive>::Recursive: WritableChannelsDescription<<SampleStorage::Pixel as IntoRecursive>::Recursive>,
315315
{
316-
SpecificChannels { channels, storage: source_samples }
316+
SpecificChannels { channels, pixels: source_samples }
317317
}
318318
}
319319

@@ -409,7 +409,7 @@ impl<RecursiveChannels: CheckDuplicates, RecursivePixel> SpecificChannelsBuilder
409409
{
410410
SpecificChannels {
411411
channels: self.channels,
412-
storage: get_pixel
412+
pixels: get_pixel
413413
}
414414
}
415415

@@ -426,7 +426,7 @@ impl<RecursiveChannels: CheckDuplicates, RecursivePixel> SpecificChannelsBuilder
426426
{
427427
SpecificChannels {
428428
channels: self.channels,
429-
storage: get_pixel
429+
pixels: get_pixel
430430
}
431431
}
432432
}
@@ -853,7 +853,7 @@ impl<C> ContainsNaN for AnyChannel<C> where C: ContainsNaN {
853853

854854
impl<S, T> ContainsNaN for SpecificChannels<S, T> where S: ContainsNaN {
855855
fn contains_nan_pixels(&self) -> bool {
856-
self.storage.contains_nan_pixels()
856+
self.pixels.contains_nan_pixels()
857857
}
858858
}
859859

src/image/read/layers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ pub trait ReadChannels<'s> {
5555

5656
/// Processes pixel blocks from a file and accumulates them into a list of layers.
5757
/// For example, `ChannelsReader` can be
58-
/// [`RgbaChannelsReader`] or [`AnyChannelsReader<FlatSamplesReader>`].
58+
/// [`SpecificChannelsReader`] or [`AnyChannelsReader<FlatSamplesReader>`].
5959
#[derive(Debug, Clone, PartialEq)]
6060
pub struct AllLayersReader<ChannelsReader> {
6161
layer_readers: SmallVec<[LayerReader<ChannelsReader>; 2]>, // TODO unpack struct?
6262
}
6363

6464
/// Processes pixel blocks from a file and accumulates them into a single layers, using only the first.
6565
/// For example, `ChannelsReader` can be
66-
/// `RgbaChannelsReader` or `AnyChannelsReader<FlatSamplesReader>`.
66+
/// `SpecificChannelsReader` or `AnyChannelsReader<FlatSamplesReader>`.
6767
#[derive(Debug, Clone, PartialEq)]
6868
pub struct FirstValidLayerReader<ChannelsReader> {
6969
layer_reader: LayerReader<ChannelsReader>,
@@ -72,7 +72,7 @@ pub struct FirstValidLayerReader<ChannelsReader> {
7272

7373
/// Processes pixel blocks from a file and accumulates them into a single layers.
7474
/// For example, `ChannelsReader` can be
75-
/// `RgbaChannelsReader` or `AnyChannelsReader<FlatSamplesReader>`.
75+
/// `SpecificChannelsReader` or `AnyChannelsReader<FlatSamplesReader>`.
7676
#[derive(Debug, Clone, PartialEq)]
7777
pub struct LayerReader<ChannelsReader> {
7878
channels_reader: ChannelsReader,

src/image/read/specific_channels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ ChannelsReader for SpecificChannelsReader<PixelStorage, SetPixel, PxReader, Pixe
214214
}
215215

216216
fn into_channels(self) -> Self::Channels {
217-
SpecificChannels { channels: self.pixel_reader.get_descriptions().into_non_recursive(), storage: self.pixel_storage }
217+
SpecificChannels { channels: self.pixel_reader.get_descriptions().into_non_recursive(), pixels: self.pixel_storage }
218218
}
219219
}
220220

src/image/write/channels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ for SpecificChannelsWriter<'channels, PxWriter, Storage, Channels>
202202
for (y, line_bytes) in byte_lines.enumerate() {
203203
pixel_line.clear();
204204
pixel_line.extend((0 .. width).map(|x|
205-
self.channels.storage.get_pixel(block_index.pixel_position + Vec2(x,y)).into_recursive()
205+
self.channels.pixels.get_pixel(block_index.pixel_position + Vec2(x, y)).into_recursive()
206206
));
207207

208208
self.recursive_channel_writer.write_pixels(line_bytes, pixel_line.as_slice(), |px| px);

tests/roundtrip.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ fn roundtrip_unusual_2() -> UnitResult {
235235

236236
// custom compare function: considers nan equal to nan
237237
assert_eq!(image.layer_data.size, size, "test is buggy");
238-
let pixels1 = &image.layer_data.channel_data.storage;
239-
let pixels2 = &image2.layer_data.channel_data.storage;
238+
let pixels1 = &image.layer_data.channel_data.pixels;
239+
let pixels2 = &image2.layer_data.channel_data.pixels;
240240

241241
assert_eq!(pixels1.pixels, pixels2.pixels);
242242

@@ -302,8 +302,8 @@ fn roundtrip_unusual_7() -> UnitResult {
302302

303303
// custom compare function: considers nan equal to nan
304304
assert_eq!(image.layer_data.size, size, "test is buggy");
305-
let pixels1 = &image.layer_data.channel_data.storage;
306-
let pixels2 = &image2.layer_data.channel_data.storage;
305+
let pixels1 = &image.layer_data.channel_data.pixels;
306+
let pixels2 = &image2.layer_data.channel_data.pixels;
307307

308308
assert_eq!(pixels1.pixels, pixels2.pixels);
309309

0 commit comments

Comments
 (0)