<commit_before>/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with main.c; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */

#include "SDL4Cpp_main.h"
#include "SDL4Cpp_video.h"

namespace SDL
{
	Uint32 MapRGB(PixelFormat &fmt, Uint8 r, Uint8 g, Uint8 b)
	{
		return SDL_MapRGB(&fmt, r, g, b);
	}

	Uint32 MapRGBA(PixelFormat &fmt, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
	{
		return SDL_MapRGBA(&fmt, r, g, b, a);
	}

	void GetRGB(Uint32 pixel, PixelFormat &fmt, Uint8 &r, Uint8 &g, Uint8 &b)
	{
		SDL_GetRGB(pixel, &fmt, &r, &g, &b);
	}

	void GetRGBA(Uint32 pixel, PixelFormat &fmt, Uint8 &r, Uint8 &g, Uint8 &b, Uint8 &a)
	{
		SDL_GetRGBA(pixel, &fmt, &r, &g, &b, &a);
	}

	/*!
	 * \brief Private SDL4Cpp_video function used for comparison
	 * Taken from the SDL manual
	 * Needed for comparison, but copy uses blit instead
	 * Return the pixel value at (x, y)
	 * NOTE: The surface must be locked before calling this!
	 */
	Uint32 getpixel(SDL_Surface *surface, int x, int y)
	{
		int bpp = surface->format->BytesPerPixel;
		/* Here p is the address to the pixel we want to retrieve */
		Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
		switch(bpp)
		{
			case 1:
				return *p;
			case 2:
				return *(Uint16 *)p;
			case 3:
				if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
					return p[0] << 16 | p[1] << 8 | p[2];
				else
					return p[0] | p[1] << 8 | p[2] << 16;
			case 4:
				return *(Uint32 *)p;
			default:
				return 0;
		}
	}

	Rect::Rect()
	{
	}

	Rect::Rect(const Rect &rect)
	{
		(*this) = rect;
	}

	Rect::Rect(int x, int y, int w, int h)
	{
		x = x;
		y = y;
		w = w;
		h = h;
	}

	Rect::Rect(const SDL_Rect &rect)
	{
		(*this) = rect;
	}<commit_msg>Fix Rect's constructor for x,y,w,h<commit_after>/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with main.c; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */

#include "SDL4Cpp_main.h"
#include "SDL4Cpp_video.h"

namespace SDL
{
	Uint32 MapRGB(PixelFormat &fmt, Uint8 r, Uint8 g, Uint8 b)
	{
		return SDL_MapRGB(&fmt, r, g, b);
	}

	Uint32 MapRGBA(PixelFormat &fmt, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
	{
		return SDL_MapRGBA(&fmt, r, g, b, a);
	}

	void GetRGB(Uint32 pixel, PixelFormat &fmt, Uint8 &r, Uint8 &g, Uint8 &b)
	{
		SDL_GetRGB(pixel, &fmt, &r, &g, &b);
	}

	void GetRGBA(Uint32 pixel, PixelFormat &fmt, Uint8 &r, Uint8 &g, Uint8 &b, Uint8 &a)
	{
		SDL_GetRGBA(pixel, &fmt, &r, &g, &b, &a);
	}

	/*!
	 * \brief Private SDL4Cpp_video function used for comparison
	 * Taken from the SDL manual
	 * Needed for comparison, but copy uses blit instead
	 * Return the pixel value at (x, y)
	 * NOTE: The surface must be locked before calling this!
	 */
	Uint32 getpixel(SDL_Surface *surface, int x, int y)
	{
		int bpp = surface->format->BytesPerPixel;
		/* Here p is the address to the pixel we want to retrieve */
		Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
		switch(bpp)
		{
			case 1:
				return *p;
			case 2:
				return *(Uint16 *)p;
			case 3:
				if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
					return p[0] << 16 | p[1] << 8 | p[2];
				else
					return p[0] | p[1] << 8 | p[2] << 16;
			case 4:
				return *(Uint32 *)p;
			default:
				return 0;
		}
	}

	Rect::Rect()
	{
	}

	Rect::Rect(const Rect &rect)
	{
		(*this) = rect;
	}

	Rect::Rect(int x, int y, int w, int h)
	{
		this->x = x;
		this->y = y;
		this->w = w;
		this->h = h;
	}

	Rect::Rect(const SDL_Rect &rect)
	{
		(*this) = rect;
	}
{'fraction_non_alphanumeric': 0.12245771783344038, 'fraction_numerical': 0.02697495183044316, 'mean_word_length': 3.228054298642534, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4473472', 'n_tokens_mistral': 1917, 'n_tokens_neox': 1696, 'n_words': 636}