Каким образом можно добавить картинку в меню [xy0/iSurface] ?
Смотрел гайды на других форумах, должного не нашёл.
Можете пожалуйста объяснить как это сделать? (Просьба не кидать ссылки на другие форумы)
Hello there fellow unknowncheats members.
Today I decided to release a function of mine which allows you to render any PNG
into CSGO.
I saw many people recently asking for this method, and help on making it.
Aswell as many people asked me how this exactly works.
So this is my response to everyone who asked me.
With this method you can do things like this.
Anyways I'm using the lodepng libary from Lode Vandevenne,
because it's pretty nicely written and it's simple to use.
So here is the code for this whole thing.
C++:
/* This are functions which are needed to make this whle thing work */
// Header
class texture
{
private:
unsigned char* chr;
unsigned int last_t;
public:
int wi , he;
texture ( std::string );
void draw ( int , int , int , int );
};
/* Functions which we will use to render the actual picture */
// This function is gathering the Width and Height from the target picture
std::vector <int> get_resulution ( std::string file_name )
{
std::ifstream in ( file_name );
unsigned int width , height;
in.seekg ( 16 );
in.read ( ( char * ) &width , 4 );
in.read ( ( char * ) &height , 4 );
width = ntohl ( width );
height = ntohl ( height );
std::vector <int> kek;
kek.push_back ( width );
kek.push_back ( height );
return kek;
}
// Main loading function
unsigned char* ldImg ( const char* filename , int w , int h )
{
std::vector<unsigned char> image;
unsigned width , height;
width = w;
height = h;
unsigned error = lodepng::decode ( image , width , height , filename );
// Just incase we get errors display them and say something is wrong
if ( error ) std::cout << "decoder error " << error << ": " << lodepng_error_text ( error ) << std::endl;
unsigned char* a = new unsigned char [ image.size ( ) ];
std::copy ( image.begin ( ) , image.end ( ) , a );
image.clear ( );
return a;
}
/* Texture class content */
// We need that
void stringConvertToChar ( std::string&str , char arr [ ] , size_t arrSize )
//To convert std::string to char[]
{
strcpy_s ( arr , arrSize , str.c_str ( ) );
return;
};
// Make a pointer using texture * texturename and init it with texturename = new texture("pngname.png") which must bne located inside of the csgo folder
texture::texture ( std::string fileName )
{
std::vector <int> res = get_resulution ( fileName );
wi = res [ 0 ];
he = res [ 1 ];
char name [ MAX_PATH ];
stringConvertToChar ( fileName , name , MAX_PATH );
chr = ldImg ( name , wi , he );
// unsigned int
last_t = 0;
}
// Drawing function for our pictures
// X Y W H
void texture::draw ( int x , int y , int x_2 , int y_2 )
{
bool m_bValid = false;
unsigned int m_iTexture;
if ( last_t = 0 || !Interfaces->Pointers->Surface->IsTextureIDValid ( last_t ) )
{
m_iTexture = Interfaces->Pointers->Surface->CreateNewTextureID ( true );
if ( m_iTexture )
return;
Interfaces->Pointers->Surface->DrawSetTextureRGBA ( m_iTexture , chr , ( unsigned int ) wi , ( unsigned int ) he , 0 , 1 );
if ( Interfaces->Pointers->Surface->IsTextureIDValid ( m_iTexture ) ) m_bValid = true;
last_t = m_iTexture;
}
else
{
m_iTexture = last_t;
}
Interfaces->Pointers->Surface->DrawSetColor ( RGBA ( 255 , 255 , 255 , 255 ) );
Interfaces->Pointers->Surface->DrawSetTexture ( m_iTexture );
Interfaces->Pointers->Surface->DrawTexturedRect ( x , y , x_2 , y_2 );
}
Note: This is not fully complete code and there are errors implemented into this find them, they are pretty easy to spot.
( 2 in total )
So this is how you would use this function if you implemented everything correctly.
1) Make a pointer from the texture class.
Example:
texture * TestTexture;
2) Init it inside of your main thread (or anything else)
TestTexture = new texture("TestTextureFile.png");
Now we have a loaded image, and drawing it is also fairly easy.
Parameters are X Y W H
as documented in the source code.