Increasing Size of Vector


HI, I need to increase the size of my vector. However the program crashes.
How do I increase the size and prevent it from crashing. Below is the vector in question.

Thanks.


1
2
3
4
    const size_t width = 256, height = 256;
    size_t no_elems = width * height * 4;
    using Image = std::vector<unsigned char>;
    std::vector<Image> Image_PNG(6000, Image(no_elems));
Last edited on
You can resize a vector using the resize member function.

 
vec.resize(new_size);
or
 
vec.resize(new_size, value_of_new_elements);
Last edited on
When I do that I get an "Unhandled Exception: System.AccessViolationExeption: Attempted to read or write protected memory. This is often an indication that other memory is corrupt"
We don't have enough information to tell what is wrong. It might be that you're accessing an array element out of bounds (e.g. Image_PNG[6005].resize(85000);) but it could also be something completely unrelated. UB/memory corruption does not necessary crash right away but can sometimes cause bugs in other parts of the program. Using a memory debugger such as valgrind (not available on Windows) or an UB/address sanitizer (supported by all major compilers, e.g. with GCC you can enable it using the compiler flag -fsanitize=address,undefined) can often help you find these kind of problems (the cause, which is not necessarily close to where the crash happens). Otherwise if you cannot figure it out yourself I recommend creating a minimal example that demonstrates the problem and post it here so that we can have a look. https://en.wikipedia.org/wiki/Minimal_reproducible_example
Last edited on
I agree with Peter's suggestion of making a Minimal reproducible example.

Some other notes:
- You are allocating a significant amount of memory. 6000 * 256 * 256 * 4 bytes = 1.57 GB. This is not a crazy amount for heavy image processing, but if your computer has a low amount of RAM, this could cause the memory allocation to throw an exception. But that would be a different exception by default than what you're seeing.
- Note that you have a vector of vector of bytes, not just a vector of bytes. Make sure you're correctly accessing both the outer and the inner elements correctly. For example, Image_PNG[0][4] would be the R value of the second pixel of the first image (assuming RGBA ordering).

vector notes:
* The normal way to add to a vector dynamically is to do vec.push_back(element).
* If you want to have the runtime check array bounds and deterministically throw an exception instead of outright crashing with an access violation, use vec.at(index) instead of vec[index] when accessing elements. This might assist in troubleshooting.

Last edited on
Here is some code. Its quite complicated so its hard to show an example.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//Encode from raw pixels to disk with a single function call
//The image argument has width * height RGBA pixels or width * height * 4 bytes
void encodeOneStep(const char* filename, std::vector<unsigned char>& image, unsigned width, unsigned height) {
    //Encode the image
    unsigned error = lodepng::encode(filename, image, width, height);

    //if there's an error, display it
    if (error) std::cout << "encoder error " << error << ": " << lodepng_error_text(error) << std::endl;
}


int main()
{
    const size_t width = 256, height = 256;
    size_t no_elems = width * height * 4;
    using Image = std::vector<unsigned char>;
    std::vector<Image> Image_PNG(2855, Image(no_elems));
    std::vector<Image> Image_PNGB(2855, Image(no_elems));


// Donkey Kong Pallette *** Checked
    static const unsigned char coloursB[16][4] = { // An array of colour values. 
       //RRR  GGG  BBB
       { 0, 0, 0, 0 }, /* White    */
       {   24,  16,  0, 255 }, /* Index  1 */
       {   64,  32, 0, 255 }, /* Index  2 */
       {  96, 48, 0, 255 }, /* Index  3 */
       {   136, 64, 0, 255 }, /* Index  4 */
       {   168, 80, 0, 255 }, /* Index  5 */
       { 192, 96, 0, 255 }, /* Index  6 */
       { 208, 112, 0, 255 }, /* Index  7 */
       { 248, 0, 0, 255 }, /* Index  8 */
       { 128, 0, 0, 255 }, /* Index  9 */
       {  152,   48,  0, 255 }, /* Index 10 */
       {   248,   128, 112, 255 }, /* Index 11 */
       {  248,  160, 144, 255 }, /* Index 12 */
       {   248, 192, 184, 255 }, /* Index 13 */
       {  248, 224,   216, 255 }, /* Index 14 */
       {   248,   248,   248, 255 }  /* Index 15 */
    };


long long int address = 0x1D70C6;  // add 0xC00000 to get the SNES address.
    int offset = 0; // The location of the next set of sprites.
    int Data_Size = 0;
    int Next_sprite = 0;
    int s = 0;
    int coord_X_Location = 0;
    int coord_Y_Location = 0;
    int x_coord = 0;
    int y_coord = 0;
    int tile_count = 0;
    int MAP_HEAD = 0;

    for (int X = 0; X <= 2855; X++)
    {

if (p <= Pixel_count && X <= 2855 && Palette_Number == 36)  // BoomBox and Cannon Ball
            {
                for (int j = 0, N = 7; j < 8; j++, N--) // Check which bits are set for each pixel of the tiles. Then assign the index colour to the image Array location.
                {
                    std::bitset<4> bs;
                    bs.set(0, (Bitplane0__ROW[p] >> N) & 1);
                    bs.set(1, (Bitplane1__ROW[p] >> N) & 1);
                    bs.set(2, (Bitplane2__ROW[p] >> N) & 1);
                    bs.set(3, (Bitplane3__ROW[p] >> N) & 1);
                    unsigned long Index = bs.to_ulong();

                    Image_PNG[X][c++] = coloursV2[Index][0]; // Red
                    Image_PNG[X][c++] = coloursV2[Index][1]; // Green
                    Image_PNG[X][c++] = coloursV2[Index][2]; // Blue 
                    Image_PNG[X][c++] = coloursV2[Index][3]; // Alpha
                }
            }
            else { Palette_Number = 37;}
            if (p <= Pixel_count && X <= 2855 && Palette_Number == 37)  // BoomBox and Cannon Ball
            {
                
            for (int j = 0, N = 7; j < 8; j++, N--) // Check which bits are set for each pixel of the tiles. Then assign the index colour to the image Array location.
            {
                std::bitset<4> bs;
                bs.set(0, (Bitplane0__ROW[p] >> N) & 1);
                bs.set(1, (Bitplane1__ROW[p] >> N) & 1);
                bs.set(2, (Bitplane2__ROW[p] >> N) & 1);
                bs.set(3, (Bitplane3__ROW[p] >> N) & 1);
                unsigned long Index = bs.to_ulong();
                Image_PNGB[X][c++] = coloursU2[Index][0]; // Red
                Image_PNGB[X][c++] = coloursU2[Index][1]; // Green
                Image_PNGB[X][c++] = coloursU2[Index][2]; // Blue 
                Image_PNGB[X][c++] = coloursU2[Index][3]; // Alpha
            }
            
            }
          
        }
        if (X <= 2855)
        {
            string combined_file_path(string(path) + "\\Diddy\\" + to_string(X) + ".png");
            encodeOneStep(combined_file_path.c_str(), Image_PNG[X], width, height);  // Write the .png image file.

            string combined_file_pathB(string(path) + "\\Diddy\\Blue\\" + to_string(X) + ".png");
            encodeOneStep(combined_file_pathB.c_str(), Image_PNGB[X], width, height);  // Write the .png image file.
        }
    }
    cout << "Extraction Complete! ";
    system("pause");
    //std::getchar();  // Prevent the console from closing,

    return 0;
}





}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/Encode from raw pixels to disk with a single function call
//The image argument has width * height RGBA pixels or width * height * 4 bytes
void encodeOneStep(const char* filename, std::vector<unsigned char>& image, unsigned width, unsigned height) {
    //Encode the image
    unsigned error = lodepng::encode(filename, image, width, height);

    //if there's an error, display it
    if (error) std::cout << "encoder error " << error << ": " << lodepng_error_text(error) << std::endl;
}


int main()
{
    const size_t width = 256, height = 256;
    size_t no_elems = width * height * 4;
    using Image = std::vector<unsigned char>;
    std::vector<Image> Image_PNG(2855, Image(no_elems));
    std::vector<Image> Image_PNGB(2855, Image(no_elems));

// Diddy Kong Pallette  ** Checked
    static const unsigned char coloursE[16][4] = { // An array of colour values. 
       //RRR  GGG  BBB  AAA
       { 0, 0, 0, 0 }, /* White    */
       {   48,  24,  8, 255 }, /* Index  1 */
       {   80,  32, 16, 255 }, /* Index  2 */
       {  104, 48, 24, 255 }, /* Index  3 */
       {   144, 64, 24, 255 }, /* Index  4 */
       {   176, 80, 32, 255 }, /* Index  5 */
       { 144, 80, 56, 255 }, /* Index  6 */
       { 200, 112, 88, 255 }, /* Index  7 */
       { 248, 152, 112, 255 }, /* Index  8 */
       { 248, 176, 136, 255 }, /* Index  9 */
       {  248,   208,  152, 255 }, /* Index 10 */
       {   168,   16, 8, 255 }, /* Index 11 */
       {  208,  24, 16, 255 }, /* Index 12 */
       {   248, 48, 32, 255 }, /* Index 13 */
       {  120, 120,  120, 255 }, /* Index 14 */
       {   248, 248,  248, 255 }  /* Index 15 */
    };

// Create the Bitplanes
    int* Bitplane0__ROW = new int[20000];
    int* Bitplane1__ROW = new int[20000];
    int* Bitplane2__ROW = new int[20000];
    int* Bitplane3__ROW = new int[20000];

long long int address = 0x1D70C6;  // add 0xC00000 to get the SNES address.
    int offset = 0; // The location of the next set of sprites.
    int Data_Size = 0;
    int Next_sprite = 0;
    int s = 0;
    int coord_X_Location = 0;
    int coord_Y_Location = 0;
    int x_coord = 0;
    int y_coord = 0;
    int tile_count = 0;
    int MAP_HEAD = 0;

    for (int X = 0; X <= 2855; X++)
    {
	 if (p <= Pixel_count && X <= 2855 && Palette_Number == 36)  // BoomBox and Cannon Ball
            {
                for (int j = 0, N = 7; j < 8; j++, N--) // Check which bits are set for each pixel of the tiles. Then assign the index colour to the image Array location.
                {
                    std::bitset<4> bs;
                    bs.set(0, (Bitplane0__ROW[p] >> N) & 1);
                    bs.set(1, (Bitplane1__ROW[p] >> N) & 1);
                    bs.set(2, (Bitplane2__ROW[p] >> N) & 1);
                    bs.set(3, (Bitplane3__ROW[p] >> N) & 1);
                    unsigned long Index = bs.to_ulong();

                    Image_PNG[X][c++] = coloursV2[Index][0]; // Red
                    Image_PNG[X][c++] = coloursV2[Index][1]; // Green
                    Image_PNG[X][c++] = coloursV2[Index][2]; // Blue 
                    Image_PNG[X][c++] = coloursV2[Index][3]; // Alpha

                    c = c - 4;
                    Image_PNGB[X][c++] = coloursU2[Index][0]; // Red
                    Image_PNGB[X][c++] = coloursU2[Index][1]; // Green
                    Image_PNGB[X][c++] = coloursU2[Index][2]; // Blue 
                    Image_PNGB[X][c++] = coloursU2[Index][3]; // Alpha
                }
            }

        }
        if (X <= 2855)
        {
            string combined_file_path(string(path) + "\\Diddy\\" + to_string(X) + ".png");
            encodeOneStep(combined_file_path.c_str(), Image_PNG[X], width, height);  // Write the .png image file.

            string combined_file_pathB(string(path) + "\\Diddy\\Blue\\" + to_string(X) + ".png");
            encodeOneStep(combined_file_pathB.c_str(), Image_PNGB[X], width, height);  // Write the .png image file.
        }
    }
    cout << "Extraction Complete! ";
    system("pause");
    //std::getchar();  // Prevent the console from closing,

    return 0;
}


}

start replacing [][] double vector access with .at calls to see if you have gone out of bounds. You can put it back (.at is rather sluggish) after you use it to debug. Eg replace all the calls in the loop in the top block after line 78, see if that tells you anything. It looks like somehow, somewhere, you probably have gone out of bounds which then prevents resize because its damaged.

I don't even see where C is defined for your [c++]. Let alone what its value might be, but its late and maybe I am just not seeing it. I see c -= 4 but not its original value.
Last edited on
No. I don't see where c is defined. But if the code compiles it must be defined somewhere at a global level. But where is it initialised? and used outside of this code?

Also note that in the second code there is c = c-4 before used with Image_PNGB but in the first code there isn't.
That is not a "Minimal reproducible example".

The most obvious code smell I see is that your outer vector size is 2855, but your for loops are going "X <= 2855".
Index 2855 itself will be out of bounds, so this seems wrong.

Also, what's up with the if (X <= 2855) check on line 86? The for loop itself is already bounded by X <= 2855, so this check doesn't do anything, which makes me believe you probably intended to check something different here.
Last edited on
I think we've been here before...
https://cplusplus.com/forum/beginner/285876/
https://cplusplus.com/forum/beginner/285888/

@Cyclone, if you're able to, put the whole project on say github.

Don't forget to include whatever input data file(s) you may have. Since you seem to be trying to pull sprites (or other image data) from SNES, be careful about potential copyright violations.

If the data files are legally available elsewhere, then point that out in the readme.
^ Sorry about that. I Moved on and then decide to give it another try lol.

My project folder is over a gig. So I just posted the main.cpp file.
If you need more files then let me know and i will post them too!

My project folder is a mess...

https://github.com/Cyclone-S/DKC-Sprite-Extractor

Also there is nothing copywrited in my git hub.

Thanks for your help. :)

Edit. Going through my project folder there are so many files I don't know which to upload...

Edit 2. Just added some Include files
Last edited on
Sorry, but I think you're missing the point of what Peter87 and I are trying to tell you.

We certainly don't want to rifle through gigabyte of stuff. The point of making a minimal reproducible example is that it helps yourself narrow down what the issue before we look at it.

Your program might be complicated, but probably 99% of the code is not contributing towards this particular access violation.

For example, I would bet that the access violation comes before you ever try to write to a file (but you could confirm this yourself with a debugger), so immediately I bet you don't actually need to call into LodePNG utilities to reproduce your error.

Copy all your code, or make a completely separate project/solution that has just the bare essentials to reproducing the access violation. Probably you're just going out of bounds somewhere. Simplify your code as much as possible such that the original problem still occurs.

https://stackoverflow.com/help/minimal-reproducible-example
https://vercel.com/guides/creating-a-minimal-reproducible-example

__________________

This is also where breaking your code into logical chunks really helps you long-term. Your main.cpp file is 2.11 MB. That is huge for a source file. The vast majority of your code seems like to be some sort of manually written sprite generation logic, which would probably be better suited as external assets, or at least separate files. You have a million magic numbers being used as array indices. You need to debug your code and figure out where the problem actually starts happening.

Also, look into unit tests. Unit tests help you test a particular subset of your code without having to think about the entire scope of the program. It's a great skill to learn.
Last edited on
Sorry I know I must be frustrating. I'm such a slow learner and get overwhelmed.

You are correct. there are way too many magic numbers... I was hesitant to post my code cuzz I was embarrassed.

I will try to make a minimal example.

Thanks for your help.

Learning to program effectively is hard. We’ve all been there.

Many times it is like when you are trying to explain something to someone. As you figure out how to explain it you clarify it in your own head.

The same is true for programming. Learning how to clarify, manage, and debug your own code helps tremendously with your own understanding and ability.

You’re doing fine. And we’re still willing to help as best we can when you get stuck. 😉



Ganado’s the GOAT
OK here is my attempt at a minimal example. This will compile in visual studio. However I still get an error when the console launches when I set the vector size above ~7000.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

#include "C:\Users\Chris\source\repos\PNG\lodepng.h"
#include "C:\Users\Chris\source\repos\PNG\lodepng.cpp"
#include <fstream>
#include <sstream>
#include <string>
#include <atlstr.h>
#include <iterator>
#include <iostream>
#include <bitset>
#include <Windows.h>
#include <vector>

using namespace std;

//Encode from raw pixels to disk with a single function call
//The image argument has width * height RGBA pixels or width * height * 4 bytes
void encodeOneStep(const char* filename, std::vector<unsigned char>& image, unsigned width, unsigned height) {
    //Encode the image
    unsigned error = lodepng::encode(filename, image, width, height);

    //if there's an error, display it
    if (error) std::cout << "encoder error " << error << ": " << lodepng_error_text(error) << std::endl;
}

int main()
{
    const size_t width = 256, height = 256;
    size_t no_elems = width * height * 4;
    using Image = std::vector<unsigned char>;
    std::vector<Image> Image_PNG(7000, Image(no_elems));  // Increasing this to more then ~7000 the program will crash

    char sztmp[1024];
    char sztmp_ROM[1024];
    const char* filepath = " ";
    const char* filepath_ROM = " ";
 
    cin.clear();
    cout << "\nEnter Directory of your Donkey Kong Country 1.0 USA ROM:\n " << endl;
    cin.getline(sztmp_ROM, sizeof(sztmp_ROM), '\n');
    std::string directory(sztmp_ROM);
    directory.erase(remove(directory.begin(), directory.end(), '\"'), directory.end());

    string path;
    const size_t last_slash_idx = directory.rfind('\\');
    if (std::string::npos != last_slash_idx)
    {
        path = directory.substr(0, last_slash_idx);
    }

    // Create Sub folders
    string combined_file_path(string(path) + "\\Diddy");
    CreateDirectory(combined_file_path.c_str(), NULL);
    cout << "\nChose a Palette";
    cin.get();

    cout << "1 Diddy\n\n";

    int Palette_Number = 0;
    std::cin >> Palette_Number;

    std::cout << "Your slection was "; std::cout << Palette_Number;

    // Boombbox and Cannonball Pallette  ** Checked
    static const unsigned char coloursV2[16][4] = { // An array of colour values. 
       //RRR  GGG  BBB
       { 0, 0, 0, 0 }, /* White    */
       {   16,  16,  16, 255 }, /* Index  1 */
       {   40,  40, 40, 255 }, /* Index  2 */
       {  56, 56, 56, 255 }, /* Index  3 */
       {   72, 72, 72, 255 }, /* Index  4 */
       {   88, 88, 88, 255 }, /* Index  5 */
       { 112, 112, 112, 255 }, /* Index  6 */
       { 128, 128, 128, 255 }, /* Index  7 */
       { 144, 144, 144, 255 }, /* Index  8 */
       { 160,   160,  160, 255 }, /* Index  9 */
       {  184,   184, 184, 255 }, /* Index 10 */
       {   200,  200, 200, 255 }, /* Index 11 */
       {  216,  216, 216, 255 }, /* Index 12 */
       {   232, 232, 232, 255 }, /* Index 13 */
       {  248, 248,   248, 255 }, /* Index 14 */
       {   8,   0,   0, 255 }  /* Index 15 */
    };

    // Create the Bitplanes
    int* Bitplane0__ROW = new int[20000];
    int* Bitplane1__ROW = new int[20000];
    int* Bitplane2__ROW = new int[20000];
    int* Bitplane3__ROW = new int[20000];

    long long int address = 0x1D70C6;  // add 0xC00000 to get the SNES address.
    int Data_Size = 0;
    int Next_sprite = 0;
    int coord_X_Location = 0;
    int coord_Y_Location = 0;
   
    int tile_count = 0;
   

    for (int X = 0; X <= 2855; X++)
    {

        int bit_offset;
        // Go to the next area in the ROM that contains sprites. Add 0XC00000 to get the snes ADDRESS
        if (X == 22) { address = 0x6DA77; Data_Size = 0; } // Diddy Part 1

        char oDataK[0x40000]; // Sprite buffer
        ifstream inFileK;
        inFileK.open(directory, ios::binary); // Note. this opens a binary stream. This is needed. cuzz the program was using 0x1a values as a Substitute AscII charter which halts the program/Using it as End Of File.
        inFileK.seekg(address + Data_Size, 1); // Seek to the current sprite header location.
        inFileK.read(oDataK, 0x40000);
        inFileK.close();

        int Header = 8;
        int number_of_large_tiles = oDataK[0]; // The number of 2x2 chars (16 x 16 pixel tiles)
        int size_of_large_tiles = oDataK[0] * 32;
        int tile_offset = 0;
        int Offset_Group_Two = oDataK[4];
        int DMA_Group_ONE = oDataK[5];
        int Size_of_coordenants = (oDataK[0] + oDataK[1]) * 2;   // 0 contains the value of the number of 2x2 chars (16 x 16 pixel tiles). 1 contains the value of the number of 1x1 chars (8x8 pixel tiles). These two values are multiplied by 2 (two bytes for each set of coordenants).

        //int Tile_Count_All = (tile_count_small * 8 + number_of_large_tiles * 32);
        int Start_Of_First_Tile = Header + Size_of_coordenants;  // 8 is the size of the header. 6 is the total size of coordinates(3 chars (tiles) * 2 bytes for earch char) (these are also part of the header...) 
        int p = 0;
        int chars_small = oDataK[1];  // The number of 1x1 chars (8 x 8 pixel tiles)
        int chars_small_Group2 = oDataK[3]; // The number of 1x1 chars Group 2 (8 x 8 pixel tiles)

       
            

        /////////////////////////////////////////////////////////////////////////////////////////////////

        Start_Of_First_Tile = Start_Of_First_Tile + Data_Size; // the location of the curent sprite.
        Data_Size = Data_Size + Header + Size_of_coordenants + (number_of_large_tiles * 4 * 32) + (chars_small * 1 * 32);
        int c = 0;
        int x_coord_Large;
        int y_coord_Large;
        coord_X_Location = tile_count;
        coord_Y_Location = tile_count + 1;
        int offset = 32;

        unsigned char oDataL[0x80000]; // Increase this value to prevent crashing?

        // Sprite buffer
        ifstream inFileL;
        inFileL.open(directory, ios::binary); // Note. this opens a binary streem. This is needed. cuzz the program was using 0x1a values as a Substitute AscII charter which halts the program/Using it as End Of File.
        inFileL.seekg(address, 1); // Seek to the current sprite header location.
        inFileL.read((char*)oDataL, 0x40000);
        inFileL.close();
        int Pixel_count = ((number_of_large_tiles * 32) + (chars_small * 8) + (chars_small_Group2 * 8));

        for (int p = 0, t = 0; p < Pixel_count; p++, t++)
        {
             // Write the PNG Images
            if (p <= Pixel_count && X <= 2855 && Palette_Number == 1)  // BoomBox and Cannon Ball
            {
                for (int j = 0, N = 7; j < 8; j++, N--) // Check which bits are set for each pixel of the tiles. Then assign the index colour to the image Array location.
                {
                    std::bitset<4> bs;
                    bs.set(0, (Bitplane0__ROW[p] >> N) & 1);
                    bs.set(1, (Bitplane1__ROW[p] >> N) & 1);
                    bs.set(2, (Bitplane2__ROW[p] >> N) & 1);
                    bs.set(3, (Bitplane3__ROW[p] >> N) & 1);
                    unsigned long Index = bs.to_ulong();

                    Image_PNG[X][c++] = coloursV2[Index][0]; // Red
                    Image_PNG[X][c++] = coloursV2[Index][1]; // Green
                    Image_PNG[X][c++] = coloursV2[Index][2]; // Blue 
                    Image_PNG[X][c++] = coloursV2[Index][3]; // Alpha
                }
            }
        }
        if (X <= 2855)
        {
            string combined_file_path(string(path) + "\\Diddy\\" + to_string(X) + ".png");
            encodeOneStep(combined_file_path.c_str(), Image_PNG[X], width, height);  // Write the .png image file.
        }
    }
    cout << "Extraction Complete! ";
    system("pause");
    return 0;
}
Registered users can post here. Sign in or register to post.