Image.cpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
26// Headers
28#include <SFML/Graphics/Image.hpp>
29#include <SFML/Graphics/ImageLoader.hpp>
30#include <SFML/Graphics/RenderWindow.hpp>
31#include <SFML/Graphics/GraphicsContext.hpp>
32#include <algorithm>
33#include <iostream>
34#include <vector>
35#include <string.h>
36
37
38namespace sf
39{
44myWidth (0),
45myHeight (0),
46myTextureWidth (0),
47myTextureHeight (0),
48myTexture (0),
49myIsSmooth (true),
50myNeedTextureUpdate(false),
51myNeedArrayUpdate (false)
52{
53
54}
55
56
62myWidth (Copy.myWidth),
63myHeight (Copy.myHeight),
64myTextureWidth (Copy.myTextureWidth),
65myTextureHeight (Copy.myTextureHeight),
66myTexture (0),
67myIsSmooth (Copy.myIsSmooth),
68myPixels (Copy.myPixels),
69myNeedTextureUpdate(false),
70myNeedArrayUpdate (false)
71{
72 CreateTexture();
73}
74
75
79Image::Image(unsigned int Width, unsigned int Height, const Color& Col) :
80myWidth (0),
81myHeight (0),
82myTextureWidth (0),
83myTextureHeight (0),
84myTexture (0),
85myIsSmooth (true),
86myNeedTextureUpdate(false),
87myNeedArrayUpdate (false)
88{
89 Create(Width, Height, Col);
90}
91
92
96Image::Image(unsigned int Width, unsigned int Height, const Uint8* Data) :
97myWidth (0),
98myHeight (0),
99myTextureWidth (0),
100myTextureHeight (0),
101myTexture (0),
102myIsSmooth (true),
103myNeedTextureUpdate(false),
104myNeedArrayUpdate (false)
105{
106 LoadFromPixels(Width, Height, Data);
107}
108
109
114{
115 // Destroy the OpenGL texture
116 DestroyTexture();
117}
118
119
123bool Image::LoadFromFile(const std::string& Filename)
124{
125 // Let the image loader load the image into our pixel array
126 bool Success = priv::ImageLoader::GetInstance().LoadImageFromFile(Filename, myPixels, myWidth, myHeight);
127
128 if (Success)
129 {
130 // Loading succeeded : we can create the texture
131 if (CreateTexture())
132 return true;
133 }
134
135 // Oops... something failed
136 Reset();
137
138 return false;
139}
140
141
145bool Image::LoadFromMemory(const char* Data, std::size_t SizeInBytes)
146{
147 // Check parameters
148 if (!Data || (SizeInBytes == 0))
149 {
150 std::cerr << "Failed to image font from memory, no data provided" << std::endl;
151 return false;
152 }
153
154 // Let the image loader load the image into our pixel array
155 bool Success = priv::ImageLoader::GetInstance().LoadImageFromMemory(Data, SizeInBytes, myPixels, myWidth, myHeight);
156
157 if (Success)
158 {
159 // Loading succeeded : we can create the texture
160 if (CreateTexture())
161 return true;
162 }
163
164 // Oops... something failed
165 Reset();
166
167 return false;
168}
169
170
174bool Image::LoadFromPixels(unsigned int Width, unsigned int Height, const Uint8* Data)
175{
176 if (Data)
177 {
178 // Store the texture dimensions
179 myWidth = Width;
180 myHeight = Height;
181
182 // Fill the pixel buffer with the specified raw data
183 const Color* Ptr = reinterpret_cast<const Color*>(Data);
184 myPixels.assign(Ptr, Ptr + Width * Height);
185
186 // We can create the texture
187 if (CreateTexture())
188 {
189 return true;
190 }
191 else
192 {
193 // Oops... something failed
194 Reset();
195 return false;
196 }
197 }
198 else
199 {
200 // No data provided : create a white image
201 return Create(Width, Height, Color(255, 255, 255, 255));
202 }
203}
204
205
209bool Image::SaveToFile(const std::string& Filename) const
210{
211 // Check if the array of pixels needs to be updated
212 EnsureArrayUpdate();
213
214 // Let the image loader save our pixel array into the image
215 return priv::ImageLoader::GetInstance().SaveImageToFile(Filename, myPixels, myWidth, myHeight);
216}
217
218
222bool Image::Create(unsigned int Width, unsigned int Height, Color Col)
223{
224 // Store the texture dimensions
225 myWidth = Width;
226 myHeight = Height;
227
228 // Recreate the pixel buffer and fill it with the specified color
229 myPixels.clear();
230 myPixels.resize(Width * Height, Col);
231
232 // We can create the texture
233 if (CreateTexture())
234 {
235 return true;
236 }
237 else
238 {
239 // Oops... something failed
240 Reset();
241 return false;
242 }
243}
244
245
249void Image::CreateMaskFromColor(Color ColorKey, Uint8 Alpha)
250{
251 // Check if the array of pixels needs to be updated
252 EnsureArrayUpdate();
253
254 // Calculate the new color (old color with no alpha)
255 Color NewColor(ColorKey.r, ColorKey.g, ColorKey.b, Alpha);
256
257 // Replace the old color by the new one
258 std::replace(myPixels.begin(), myPixels.end(), ColorKey, NewColor);
259
260 // The texture will need to be updated
261 myNeedTextureUpdate = true;
262}
263
264
270void Image::Copy(const Image& Source, unsigned int DestX, unsigned int DestY, const IntRect& SourceRect, bool ApplyAlpha)
271{
272 // Make sure both images are valid
273 if ((Source.myWidth == 0) || (Source.myHeight == 0) || (myWidth == 0) || (myHeight == 0))
274 return;
275
276 // Make sure both images have up-to-date arrays
277 EnsureArrayUpdate();
278 Source.EnsureArrayUpdate();
279
280 // Adjust the source rectangle
281 IntRect SrcRect = SourceRect;
282 if (SrcRect.GetWidth() == 0 || (SrcRect.GetHeight() == 0))
283 {
284 SrcRect.Left = 0;
285 SrcRect.Top = 0;
286 SrcRect.Right = Source.myWidth;
287 SrcRect.Bottom = Source.myHeight;
288 }
289 else
290 {
291 if (SrcRect.Left < 0) SrcRect.Left = 0;
292 if (SrcRect.Top < 0) SrcRect.Top = 0;
293 if (SrcRect.Right > static_cast<int>(Source.myWidth)) SrcRect.Right = Source.myWidth;
294 if (SrcRect.Bottom > static_cast<int>(Source.myHeight)) SrcRect.Bottom = Source.myHeight;
295 }
296
297 // Then find the valid bounds of the destination rectangle
298 int Width = SrcRect.GetWidth();
299 int Height = SrcRect.GetHeight();
300 if (DestX + Width > myWidth) Width = myWidth - DestX;
301 if (DestY + Height > myHeight) Height = myHeight - DestY;
302
303 // Make sure the destination area is valid
304 if ((Width <= 0) || (Height <= 0))
305 return;
306
307 // Precompute as much as possible
308 int Pitch = Width * 4;
309 int Rows = Height;
310 int SrcStride = Source.myWidth * 4;
311 int DstStride = myWidth * 4;
312 const Uint8* SrcPixels = Source.GetPixelsPtr() + (SrcRect.Left + SrcRect.Top * Source.myWidth) * 4;
313 Uint8* DstPixels = reinterpret_cast<Uint8*>(&myPixels[0]) + (DestX + DestY * myWidth) * 4;
314
315 // Copy the pixels
316 if (ApplyAlpha)
317 {
318 // Interpolation using alpha values, pixel by pixel (slower)
319 for (int i = 0; i < Rows; ++i)
320 {
321 for (int j = 0; j < Width; ++j)
322 {
323 // Get a direct pointer to the components of the current pixel
324 const Uint8* Src = SrcPixels + j * 4;
325 Uint8* Dst = DstPixels + j * 4;
326
327 // Interpolate RGB components using the alpha value of the source pixel
328 Uint8 Alpha = Src[3];
329 Dst[0] = (Src[0] * Alpha + Dst[0] * (255 - Alpha)) / 255;
330 Dst[1] = (Src[1] * Alpha + Dst[1] * (255 - Alpha)) / 255;
331 Dst[2] = (Src[2] * Alpha + Dst[2] * (255 - Alpha)) / 255;
332 }
333
334 SrcPixels += SrcStride;
335 DstPixels += DstStride;
336 }
337 }
338 else
339 {
340 // Optimized copy ignoring alpha values, row by row (faster)
341 for (int i = 0; i < Rows; ++i)
342 {
343 memcpy(DstPixels, SrcPixels, Pitch);
344 SrcPixels += SrcStride;
345 DstPixels += DstStride;
346 }
347 }
348
349 // The texture will need an update
350 myNeedTextureUpdate = true;
351}
352
353
358bool Image::CopyScreen(RenderWindow& Window, const IntRect& SourceRect)
359{
360 // Adjust the source rectangle
361 IntRect SrcRect = SourceRect;
362 if (SrcRect.GetWidth() == 0 || (SrcRect.GetHeight() == 0))
363 {
364 SrcRect.Left = 0;
365 SrcRect.Top = 0;
366 SrcRect.Right = Window.GetWidth();
367 SrcRect.Bottom = Window.GetHeight();
368 }
369 else
370 {
371 if (SrcRect.Left < 0) SrcRect.Left = 0;
372 if (SrcRect.Top < 0) SrcRect.Top = 0;
373 if (SrcRect.Right > static_cast<int>(Window.GetWidth())) SrcRect.Right = Window.GetWidth();
374 if (SrcRect.Bottom > static_cast<int>(Window.GetHeight())) SrcRect.Bottom = Window.GetHeight();
375 }
376
377 // Store the texture dimensions
378 myWidth = SrcRect.GetWidth();
379 myHeight = SrcRect.GetHeight();
380
381 // We can then create the texture
382 if (Window.SetActive() && CreateTexture())
383 {
384 GLint PreviousTexture;
385 GLCheck(glGetIntegerv(GL_TEXTURE_BINDING_2D, &PreviousTexture));
386
387 GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
388 GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, SrcRect.Left, SrcRect.Top, myWidth, myHeight));
389
390 GLCheck(glBindTexture(GL_TEXTURE_2D, PreviousTexture));
391
392 myNeedTextureUpdate = false;
393 myNeedArrayUpdate = true;
394
395 return true;
396 }
397 else
398 {
399 Reset();
400 return false;
401 }
402}
403
404
408void Image::SetPixel(unsigned int X, unsigned int Y, const Color& Col)
409{
410 // First check if the array of pixels needs to be updated
411 EnsureArrayUpdate();
412
413 // Check if pixel is whithin the image bounds
414 if ((X >= myWidth) || (Y >= myHeight))
415 {
416 std::cerr << "Cannot set pixel (" << X << "," << Y << ") for image "
417 << "(width = " << myWidth << ", height = " << myHeight << ")" << std::endl;
418 return;
419 }
420
421 myPixels[X + Y * myWidth] = Col;
422
423 // The texture will need to be updated
424 myNeedTextureUpdate = true;
425}
426
427
431const Color& Image::GetPixel(unsigned int X, unsigned int Y) const
432{
433 // First check if the array of pixels needs to be updated
434 EnsureArrayUpdate();
435
436 // Check if pixel is whithin the image bounds
437 if ((X >= myWidth) || (Y >= myHeight))
438 {
439 std::cerr << "Cannot get pixel (" << X << "," << Y << ") for image "
440 << "(width = " << myWidth << ", height = " << myHeight << ")" << std::endl;
441 return Color::Black;
442 }
443
444 return myPixels[X + Y * myWidth];
445}
446
447
453const Uint8* Image::GetPixelsPtr() const
454{
455 // First check if the array of pixels needs to be updated
456 EnsureArrayUpdate();
457
458 if (!myPixels.empty())
459 {
460 return reinterpret_cast<const Uint8*>(&myPixels[0]);
461 }
462 else
463 {
464 std::cerr << "Trying to access the pixels of an empty image" << std::endl;
465 return NULL;
466 }
467}
468
469
473void Image::Bind() const
474{
475 // First check if the texture needs to be updated
476 EnsureTextureUpdate();
477
478 // Bind it
479 if (myTexture)
480 {
481 GLCheck(glEnable(GL_TEXTURE_2D));
482 GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
483 }
484}
485
486
490void Image::SetSmooth(bool Smooth)
491{
492 if (Smooth != myIsSmooth)
493 {
494 myIsSmooth = Smooth;
495
496 if (myTexture)
497 {
498 // Make sure we have a valid context
499 priv::GraphicsContext Ctx;
500
501 GLint PreviousTexture;
502 GLCheck(glGetIntegerv(GL_TEXTURE_BINDING_2D, &PreviousTexture));
503
504 GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
505 GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
506 GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
507
508 GLCheck(glBindTexture(GL_TEXTURE_2D, PreviousTexture));
509 }
510 }
511}
512
513
517unsigned int Image::GetWidth() const
518{
519 return myWidth;
520}
521
522
526unsigned int Image::GetHeight() const
527{
528 return myHeight;
529}
530
531
535bool Image::IsSmooth() const
536{
537 return myIsSmooth;
538}
539
540
545FloatRect Image::GetTexCoords(const IntRect& Rect) const
546{
547 float Width = static_cast<float>(myTextureWidth);
548 float Height = static_cast<float>(myTextureHeight);
549
550 return FloatRect(Rect.Left / Width,
551 Rect.Top / Height,
552 Rect.Right / Width,
553 Rect.Bottom / Height);
554}
555
556
560unsigned int Image::GetValidTextureSize(unsigned int Size)
561{
562 // Make sure we have a valid context
563 priv::GraphicsContext Ctx;
564
565 if (glewIsSupported("GL_ARB_texture_non_power_of_two") != 0)
566 {
567 // If hardware supports NPOT textures, then just return the unmodified size
568 return Size;
569 }
570 else
571 {
572 // If hardware doesn't support NPOT textures, we calculate the nearest power of two
573 unsigned int PowerOfTwo = 1;
574 while (PowerOfTwo < Size)
575 PowerOfTwo *= 2;
576
577 return PowerOfTwo;
578 }
579}
580
581
586{
587 Image Temp(Other);
588
589 std::swap(myWidth, Temp.myWidth);
590 std::swap(myHeight, Temp.myHeight);
591 std::swap(myTextureWidth, Temp.myTextureWidth);
592 std::swap(myTextureHeight, Temp.myTextureHeight);
593 std::swap(myTexture, Temp.myTexture);
594 std::swap(myIsSmooth, Temp.myIsSmooth);
595 std::swap(myNeedArrayUpdate, Temp.myNeedArrayUpdate);
596 std::swap(myNeedTextureUpdate, Temp.myNeedTextureUpdate);
597 myPixels.swap(Temp.myPixels);
598
599 return *this;
600}
601
602
606bool Image::CreateTexture()
607{
608 // Check if texture parameters are valid before creating it
609 if (!myWidth || !myHeight)
610 return false;
611
612 // Make sure we have a valid context
613 priv::GraphicsContext Ctx;
614
615 // Adjust internal texture dimensions depending on NPOT textures support
616 unsigned int TextureWidth = GetValidTextureSize(myWidth);
617 unsigned int TextureHeight = GetValidTextureSize(myHeight);
618
619 // Check the maximum texture size
620 GLint MaxSize;
621 GLCheck(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxSize));
622 if ((TextureWidth > static_cast<unsigned int>(MaxSize)) || (TextureHeight > static_cast<unsigned int>(MaxSize)))
623 {
624 std::cerr << "Failed to create image, its internal size is too high (" << TextureWidth << "x" << TextureHeight << ")" << std::endl;
625 return false;
626 }
627
628 // Destroy the previous OpenGL texture if it already exists with another size
629 if ((TextureWidth != myTextureWidth) || (TextureHeight != myTextureHeight))
630 {
631 DestroyTexture();
632 myTextureWidth = TextureWidth;
633 myTextureHeight = TextureHeight;
634 }
635
636 // Create the OpenGL texture
637 if (!myTexture)
638 {
639 GLint PreviousTexture;
640 GLCheck(glGetIntegerv(GL_TEXTURE_BINDING_2D, &PreviousTexture));
641
642 GLuint Texture = 0;
643 GLCheck(glGenTextures(1, &Texture));
644 GLCheck(glBindTexture(GL_TEXTURE_2D, Texture));
645 GLCheck(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, myTextureWidth, myTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
646 GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP));
647 GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP));
648 GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
649 GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
650 myTexture = static_cast<unsigned int>(Texture);
651
652 GLCheck(glBindTexture(GL_TEXTURE_2D, PreviousTexture));
653 }
654
655 myNeedTextureUpdate = true;
656
657 return true;
658}
659
660
665void Image::EnsureTextureUpdate() const
666{
667 if (myNeedTextureUpdate)
668 {
669 // Copy the pixels
670 if (myTexture && !myPixels.empty())
671 {
672 GLint PreviousTexture;
673 GLCheck(glGetIntegerv(GL_TEXTURE_BINDING_2D, &PreviousTexture));
674
675 // Update the texture with the pixels array in RAM
676 GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
677 GLCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, myWidth, myHeight, GL_RGBA, GL_UNSIGNED_BYTE, &myPixels[0]));
678
679 GLCheck(glBindTexture(GL_TEXTURE_2D, PreviousTexture));
680 }
681
682 myNeedTextureUpdate = false;
683 }
684}
685
686
691void Image::EnsureArrayUpdate() const
692{
693 if (myNeedArrayUpdate)
694 {
695 // Save the previous texture
696 GLint PreviousTexture;
697 GLCheck(glGetIntegerv(GL_TEXTURE_BINDING_2D, &PreviousTexture));
698
699 // Resize the destination array of pixels
700 myPixels.resize(myWidth * myHeight);
701
702 if ((myWidth == myTextureWidth) && (myHeight == myTextureHeight))
703 {
704 // Texture and array have the same size, we can use a direct copy
705
706 // Copy pixels from texture to array
707 GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
708 GLCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &myPixels[0]));
709 }
710 else
711 {
712 // Texture and array don't have the same size, we have to use a slower algorithm
713
714 // All the pixels will first be copied to a temporary array
715 std::vector<Color> AllPixels(myTextureWidth * myTextureHeight);
716 GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
717 GLCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &AllPixels[0]));
718
719 // The we copy the useful pixels from the temporary array to the final one
720 const Color* Src = &AllPixels[0];
721 Color* Dst = &myPixels[0];
722 for (unsigned int i = 0; i < myHeight; ++i)
723 {
724 std::copy(Src, Src + myWidth, Dst);
725 Src += myTextureWidth;
726 Dst += myWidth;
727 }
728 }
729
730 // Restore the previous texture
731 GLCheck(glBindTexture(GL_TEXTURE_2D, PreviousTexture));
732
733 myNeedArrayUpdate = false;
734 }
735}
736
737
741void Image::Reset()
742{
743 DestroyTexture();
744
745 myWidth = 0;
746 myHeight = 0;
747 myTextureWidth = 0;
748 myTextureHeight = 0;
749 myTexture = 0;
750 myIsSmooth = true;
751 myNeedTextureUpdate = false;
752 myNeedArrayUpdate = false;
753 myPixels.clear();
754}
755
756
760void Image::DestroyTexture()
761{
762 // Destroy the internal texture
763 if (myTexture)
764 {
765 // Make sure we have a valid context
766 priv::GraphicsContext Ctx;
767
768 GLuint Texture = static_cast<GLuint>(myTexture);
769 GLCheck(glDeleteTextures(1, &Texture));
770 myTexture = 0;
771 myNeedTextureUpdate = false;
772 myNeedArrayUpdate = false;
773 }
774}
775
776} // namespace sf
Color is an utility class for manipulating 32-bits RGBA colors.
Definition Color.hpp:41
Uint8 g
Green component.
Definition Color.hpp:117
Uint8 b
Blue component.
Definition Color.hpp:118
Uint8 r
Red component.
Definition Color.hpp:116
static const Color Black
Black predefined color.
Definition Color.hpp:104
unsigned int GetHeight() const
Return the height of the image.
Definition Image.cpp:526
~Image()
Destructor.
Definition Image.cpp:113
void Bind() const
Bind the image for rendering.
Definition Image.cpp:473
bool SaveToFile(const std::string &Filename) const
Save the content of the image to a file.
Definition Image.cpp:209
const Uint8 * GetPixelsPtr() const
Get a read-only pointer to the array of pixels (RGBA 8 bits integers components) Array size is GetWid...
Definition Image.cpp:453
void Copy(const Image &Source, unsigned int DestX, unsigned int DestY, const IntRect &SourceRect=IntRect(0, 0, 0, 0), bool ApplyAlpha=false)
Copy pixels from another image onto this one.
Definition Image.cpp:270
bool Create(unsigned int Width, unsigned int Height, Color Col=Color(0, 0, 0, 255))
Create an empty image.
Definition Image.cpp:222
Image & operator=(const Image &Other)
Assignment operator.
Definition Image.cpp:585
void SetPixel(unsigned int X, unsigned int Y, const Color &Col)
Change the color of a pixel.
Definition Image.cpp:408
bool LoadFromPixels(unsigned int Width, unsigned int Height, const Uint8 *Data)
Load the image directly from an array of pixels.
Definition Image.cpp:174
unsigned int GetWidth() const
Return the width of the image.
Definition Image.cpp:517
bool LoadFromMemory(const char *Data, std::size_t SizeInBytes)
Load the image from a file in memory.
Definition Image.cpp:145
const Color & GetPixel(unsigned int X, unsigned int Y) const
Get a pixel from the image.
Definition Image.cpp:431
bool LoadFromFile(const std::string &Filename)
Load the image from a file.
Definition Image.cpp:123
bool CopyScreen(RenderWindow &Window, const IntRect &SourceRect=IntRect(0, 0, 0, 0))
Create the image from the current contents of the given window.
Definition Image.cpp:358
static unsigned int GetValidTextureSize(unsigned int Size)
Get a valid texture size according to hardware support.
Definition Image.cpp:560
Image()
Default constructor.
Definition Image.cpp:43
FloatRect GetTexCoords(const IntRect &Rect) const
Convert a subrect expressed in pixels, into float texture coordinates.
Definition Image.cpp:545
void SetSmooth(bool Smooth)
Enable or disable image smooth filter.
Definition Image.cpp:490
bool IsSmooth() const
Tells whether the smooth filtering is enabled or not.
Definition Image.cpp:535
void CreateMaskFromColor(Color ColorKey, Uint8 Alpha=0)
Create transparency mask from a specified colorkey.
Definition Image.cpp:249
Rect is an utility class for manipulating rectangles.
Definition Rect.hpp:42
T GetWidth() const
Get the width of the rectangle.
Definition Rect.hpp:59
T GetHeight() const
Get the height of the rectangle.
Definition Rect.hpp:69
T Top
Top coordinate of the rectangle.
Definition Rect.hpp:113
T Right
Right coordinate of the rectangle.
Definition Rect.hpp:114
T Left
Left coordinate of the rectangle.
Definition Rect.hpp:112
T Bottom
Bottom coordinate of the rectangle.
Definition Rect.hpp:115
Simple wrapper for sf::Window that allows easy 2D rendering.
Window is a rendering window ; it can create a new window or connect to an existing one.
unsigned int GetWidth() const
Get the width of the rendering region of the window.
Definition Window.cpp:191
bool SetActive(bool Active=true) const
Activate of deactivate the window as the current target for rendering.
Definition Window.cpp:338
unsigned int GetHeight() const
Get the height of the rendering region of the window.
Definition Window.cpp:200