Page 4 of 4

Re: Custom Sprites [v1.5]

Posted: July 29th, 2013, 2:45 am
by alexkls24
I'm actually surprized that so few people commented on this one, and i just wanted to say a big thanks to you Lux for making our lives easier dealing and managing all these putpixel commands ;)

Re: Custom Sprites [v1.5]

Posted: July 29th, 2013, 4:05 am
by Asimov
Hi alex,

Luxs program is great. However later you will find you can load pngs straight from the GDI which is easier.

I know use directx sprites which are even easier to use. Working on a small game now, but still have to finish my model before I can carry on with it heh heh.

Re: Custom Sprites [v1.5]

Posted: July 29th, 2013, 8:22 am
by LuX
No problem.

Re: Custom Sprites [v1.5]

Posted: September 19th, 2013, 6:15 am
by xXFracXx
Thank you so so much for making this! I was going crazy thinking about the sprites I would have to manually make, Thanks a lot ^-^

Re: Custom Sprites [v1.5]

Posted: May 11th, 2019, 11:08 am
by binbinhfr
Hi guys,
did I miss something ? I can download the EXE / rar file of this code at the beginning of this thread, but I do not find the VB code itself, despite the fact that some of you are talking about this code...

Re: Custom Sprites [v1.5]

Posted: May 11th, 2019, 6:49 pm
by albinopapa
Sorry to say, but LuX hasn't been active in these forums for three years now. I don't think he ever posted the full source code, but on page two or three he posted a snippet of the code. If you are specifically looking for VB code then I'm not sure what to say, but chili does have a sprite conversion to the mass putpixel calls written in C++ called fukbmp. His source code is downloadable from that thread.

Re: Custom Sprites [v1.5]

Posted: May 11th, 2019, 8:06 pm
by krautersuppe
While at it, did LuX ever release his"Purity" somewhere?

Re: Custom Sprites [v1.5]

Posted: May 15th, 2019, 4:32 pm
by chili
Not that I recall...

Re: Custom Sprites [v1.5]

Posted: May 15th, 2019, 4:35 pm
by chili
Here is a simple single-file program that will convert images to putpixel code. It should be easy enough to modify to suit various purposes.

Code: Select all

#define NOMINMAX
#include <windows.h>
#include <algorithm>
namespace Gdiplus
{
    using std::min;
    using std::max;
}
#include <gdiplus.h>
#include <fstream>
#include <string>
#include <experimental\filesystem>

#pragma comment(lib,"gdiplus.lib")

namespace fs = std::experimental::filesystem::v1;
namespace gdi = Gdiplus;

const std::string in_path = "images";
const std::string out_path = "code";
const std::string out_ext = ".txt";
const gdi::Color alphakey( 192,192,192 );

int main()
{
    gdi::GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    gdi::GdiplusStartup( &gdiplusToken,&gdiplusStartupInput,nullptr );

    for( const auto& e : fs::directory_iterator( in_path ) )
    {        
        if( e.status().type() == fs::_File_type::regular )
        {
            const fs::path p = e;
            if( p.extension() == ".png" )
            {
                std::ofstream out_file( out_path + "\\" + p.stem().generic_string() + out_ext );
                gdi::Bitmap bitmap( p.c_str() );

                for( size_t y = 0; y < bitmap.GetHeight(); y++ )
                {
                    for( size_t x = 0; x < bitmap.GetWidth(); x++ )
                    {
                        gdi::Color pixel;
                        bitmap.GetPixel( x,y,&pixel );
                        if( pixel.GetValue() != alphakey.GetValue() )
                        {
                            out_file << "\tgfx.PutPixel( " << x << " + x," << y << " + y,"
                                << int( pixel.GetR() ) << "," 
                                << int( pixel.GetG() ) << "," 
                                << int( pixel.GetB() ) << " );\n";
                        }
                    }
                }
            }
        }
    }

    gdi::GdiplusShutdown( gdiplusToken );
    return 0;
}