Custom Sprites [v1.5]

The Partridge Family were neither partridges nor a family. Discuss.
alexkls24
Posts: 1
Joined: July 26th, 2013, 2:15 pm

Re: Custom Sprites [v1.5]

Post by alexkls24 » July 29th, 2013, 2:45 am

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 ;)

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Custom Sprites [v1.5]

Post by Asimov » July 29th, 2013, 4:05 am

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.
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Custom Sprites [v1.5]

Post by LuX » July 29th, 2013, 8:22 am

No problem.
ʕ •ᴥ•ʔ

xXFracXx
Posts: 45
Joined: September 6th, 2013, 8:29 am

Re: Custom Sprites [v1.5]

Post by xXFracXx » September 19th, 2013, 6:15 am

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 ^-^

binbinhfr
Posts: 9
Joined: May 9th, 2019, 10:57 pm

Re: Custom Sprites [v1.5]

Post by binbinhfr » May 11th, 2019, 11:08 am

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...

albinopapa
Posts: 3709
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Custom Sprites [v1.5]

Post by albinopapa » May 11th, 2019, 6:49 pm

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.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
krautersuppe
Posts: 73
Joined: September 14th, 2015, 10:58 pm
Location: Istanbul

Re: Custom Sprites [v1.5]

Post by krautersuppe » May 11th, 2019, 8:06 pm

While at it, did LuX ever release his"Purity" somewhere?
Kraut

User avatar
chili
Site Admin
Posts: 3808
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Custom Sprites [v1.5]

Post by chili » May 15th, 2019, 4:32 pm

Not that I recall...
Chili

User avatar
chili
Site Admin
Posts: 3808
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Custom Sprites [v1.5]

Post by chili » May 15th, 2019, 4:35 pm

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;
}
Chili

Post Reply