Lesson 8 Crap

The Partridge Family were neither partridges nor a family. Discuss.
MadMalcolm
Posts: 2
Joined: March 13th, 2019, 8:50 pm

Re: Lesson 8 Crap

Post by MadMalcolm » March 14th, 2019, 3:42 am

Is the year time stamp correct? Nuts...anyways. What if you were sooo stupid you couldn't figure out how to use fukbmp? I would rather ask for help here as opposed to the you tube comments. If nobody responds within a day I will probably try the help forum should I feel so inclined. I will just keep trying. I just want to understand it before I move on....sort of. Thanks in advance.

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

Re: Lesson 8 Crap

Post by chili » March 14th, 2019, 6:46 am

What you tryin to do?
Chili

MadMalcolm
Posts: 2
Joined: March 13th, 2019, 8:50 pm

Re: Lesson 8 Crap

Post by MadMalcolm » March 14th, 2019, 11:04 pm

I can't figure out how to use Fukbmp. Thanks for the reply but I really should be able to figure it out. It must be inside the code somewhere. If I still can't after today I will try back. Thanks for the video's. Awesome humor in them!

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

Re: Lesson 8 Crap

Post by chili » March 16th, 2019, 2:22 am

Hmmm, it's been so goddamn long I don't really recall it myself.

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;
}
Here is what I used for the new series (think of it as fukbmp V2)
Chili

Post Reply