fx: debug statement
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
use image::{DynamicImage, ImageReader};
|
use image::{DynamicImage, ImageReader};
|
||||||
use log::info;
|
use log::trace;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
objects::{hit::Hit, materials::traits::Material},
|
objects::{hit::Hit, materials::traits::Material},
|
||||||
@@ -18,8 +18,15 @@ pub struct Texture {
|
|||||||
impl Texture {
|
impl Texture {
|
||||||
pub fn new(texture: &str) -> Self {
|
pub fn new(texture: &str) -> Self {
|
||||||
let img = ImageReader::open(texture).unwrap().decode().unwrap(); // FIXME: unwraps
|
let img = ImageReader::open(texture).unwrap().decode().unwrap(); // FIXME: unwraps
|
||||||
info!("{} * {} = {} bytes", img.width(), img.height(), img.as_bytes().len());
|
trace!(
|
||||||
let stride = match img.color() { // TODO: support other types of image
|
"texture '{}' is {} by {} pixels, with {} bytes total",
|
||||||
|
texture,
|
||||||
|
img.width(),
|
||||||
|
img.height(),
|
||||||
|
img.as_bytes().len()
|
||||||
|
);
|
||||||
|
let stride = match img.color() {
|
||||||
|
// TODO: support other types of image
|
||||||
image::ColorType::L8 => todo!(),
|
image::ColorType::L8 => todo!(),
|
||||||
image::ColorType::La8 => todo!(),
|
image::ColorType::La8 => todo!(),
|
||||||
image::ColorType::Rgb8 => 3,
|
image::ColorType::Rgb8 => 3,
|
||||||
@@ -51,7 +58,11 @@ impl Texture {
|
|||||||
let b = self.source.as_bytes();
|
let b = self.source.as_bytes();
|
||||||
let idx = self._idx(u, v);
|
let idx = self._idx(u, v);
|
||||||
|
|
||||||
Vec3::from_u8(b[self.stride * idx], b[self.stride * idx + 2], b[self.stride * idx + 1])
|
Vec3::from_u8(
|
||||||
|
b[self.stride * idx],
|
||||||
|
b[self.stride * idx + 2],
|
||||||
|
b[self.stride * idx + 1],
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user