Visual Computing Library
Loading...
Searching...
No Matches
texture.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_SPACE_CORE_TEXTURE_H
24#define VCL_SPACE_CORE_TEXTURE_H
25
26#include "image.h"
27
28#include <vclib/io/file_info.h>
29#include <vclib/io/serialization.h>
30
31namespace vcl {
32
34{
35 Image mImg;
36 std::string mPath;
37
38public:
39 Texture() {}
40
46 Texture(const std::string& path) : mPath(path) { mImg.load(path); }
47
54 Texture(const Image& img, const std::string& path) : mImg(img), mPath(path)
55 {
56 }
57
64 Texture(Image&& img, const std::string& path) :
65 mImg(std::move(img)), mPath(path)
66 {
67 }
68
74 const std::string& path() const { return mPath; }
75
81 std::string& path() { return mPath; }
82
88 const Image& image() const { return mImg; }
89
95 Image& image() { return mImg; }
96
97 void serialize(std::ostream& os) const
98 {
99 vcl::serialize(os, mPath);
100 mImg.serialize(os);
101 }
102
103 void deserialize(std::istream& is)
104 {
105 vcl::deserialize(is, mPath);
106 mImg.deserialize(is);
107 }
108};
109
110} // namespace vcl
111
112#endif // VCL_SPACE_CORE_TEXTURE_H
The Image class stores an Image in 4 bytes RGBA format.
Definition image.h:44
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
Definition texture.h:34
Texture(const std::string &path)
Load a texture from a file.
Definition texture.h:46
Texture(Image &&img, const std::string &path)
Creates a Texture object, with the given image and its path.
Definition texture.h:64
std::string & path()
Get the path of the texture.
Definition texture.h:81
const Image & image() const
Get the image of the texture.
Definition texture.h:88
Texture(const Image &img, const std::string &path)
Creates a Texture object, with the given image and its path.
Definition texture.h:54
const std::string & path() const
Get the path of the texture.
Definition texture.h:74
Image & image()
Get the image of the texture.
Definition texture.h:95