There are four APIs.
Two of them are functions equivalent to the c/c++ standard library functions rand()/srand(int seed), namely bluenoise()/sbluenoise(int seed).
Another one is bluenoiseex(), which returns a wider range of bluenoise than 0 to RAND_MAX. It returns bluenoise in the range of 0 to 65535 even in the initial state, so it is more high-resolution than bluenoise.

If you use bluenoiseex() frequently, you can use additional APIs to increase the size of the bluenoise matrix.
It generates bluenoise in the range of 0 to 0x07ffffff.
If you call the additional API, the bluenoise matrix will use the file specified by the additional API.
If you don't call the additional API, the file will not be used, and a pre-initialized table of size 256x256 will be used.

  1. sbluenoise(int seed) corresponding to srand(int seed)
  2. Changes the bluenoise sequence.
    If you call the additional API, reading the table from the file and the required memory for reading will be necessary when calling bluenoise()/bluenoiseex()/sbluenoise() for the first time.
    If you don't call the additional API, there is no overhead for the first call.
  3. blunenoise() corresponding to rand()
  4. Generates bluenoise in the range of 0 to RAND_MAX.
    If you use bluenoise, you don't need to call the additional API setbluenoisematrix.
  5. blunenoiseex() to generate high-resolution bluenoise
  6. Generates bluenoise in the range of 0 to size * size.
    It generates higher-resolution bluenoise than the bluenoise() API even without using the additional API.
    Using the additional API allows you to obtain bluenoise series in the range of 0 to 0x0fffffff.
  7. Additional APIs
  8. It is a special API that most people never use. If you use the blunenoiseex() API, the larger the size of the bluenoise matrix, the higher the quality.
    If you use the blunenoise() API, even if you generate this API, the generated bluenoise is just a rough sequence in the range of 0 to RAND_MAX (0x7fff).

    To use the table called the bluenoise matrix, specify the folder for saving the matrix table and specify the size of the matrix table as an argument.
    At the same time as setting, use a matrix table specified in one of the sizes: 512x512, 1024x1024, 2048x2048, 4096x4096, 8192x8192, 16384x16384.
    In normal use, calling this API is not necessary. If you only need "high-resolution bluenoise," a bluenoise of about 1024x1024 is sufficient. If there is a special purpose (performing systematic dithering on a large printer exceeding A0, initializing a huge matrix with a bluenoise sequence, etc.), use a matrix of 2048x2048 or larger, but the file size and the memory for loading the matrix will be large.
    If there is no matrix table of the specified size in the set folder, a new table will be created.
    The file size of the table is as follows. The size of the required memory for reading is approximately equal to the file size.
    If you want to use the original table of size 256x256, set NULL or "" as the folder name.
Matrix SizeRange of Values Generated by bluenoiseex()File SizeRange of Values Generated by bluenoise()
256×2560~0x0000ffff(0~65,535)No file, as it is embedded data0~0x00007fff(0~32,767)
512×5120~0x0003ffff(0~262,143)1 Megabyte0~0x00007fff(0~32,767)
1024×10240~0x000fffff(0~1,048,575)
Sufficient for substitution of a million random sequence numbers
4 Megabytes0~0x00007fff(0~32,767)
2048×20480~0x003fffff(0~4,194,303)16 Megabytes0~0x00007fff(0~32,767)
4096×40960~0x00ffffff(0~16,777,215)
Number of colors in a 24-bit color image
64 Megabytes0~0x00007fff(0~32,767)
8192×81920~0x03ffffff(0~67,108,863)
Only used with a special printer (for creating national treasure archives) with a printing width of 8 meters
256 Megabytes0~0x00007fff(0~32,767)
16384×163840~0x0fffffff(0~268,435,455)
No examples found using this level of precision (possibility of dividing into four 8192×8192 matrices for CMYK use)
1024 Megabytes (1 Gigabyte)0~0x00007fff(0~32,767)

Loading and Unloading DLLs

The definition for each API is as follows in "bluenoisecallback.h".
///////////////////////////////
// Setting the seed for the blue noise sequence
//  int				seed;		seed value
// Return value
//   Negative....Error(INITIALIZE_ERROR...Initialization error(failed to create an instance of the class: insufficient memory))
typedef int (__stdcall* SBLUENOISE)(int seed);
extern SBLUENOISE sbluenoise;
/////////////////////////
// Obtaining the blue noise sequence (0~RAND_MAX)
// RAND_MAX is 0x7fff(32767), so it is coarse
// Return value
//   Negative....Error(INITIALIZE_ERROR...Initialization error(failed to create an instance of the class: insufficient memory))
//   Blue noise sequence
typedef int (__stdcall* BLUENOISE)();
extern BLUENOISE bluenoise;
/////////////////////////
// Obtaining a detailed blue noise sequence (0~size*size)
// Even without using a file (256*256), it can be fine-tuned from 0 to 65535
//   256*  256       0~0x0000ffff(0 to     65,536-1)      Not using a file
//   512*  512       0~0x0003ffff(0 to    262,144-1)       1MB
//  1024* 1024       0~0x000fffff(0 to  1,048,576-1)         4MB
//  2048* 2048       0~0x003fffff(0 to  4,194,304-1)        16MB
//  4096* 4096       0~0x00ffffff(0 to 16,777,216-1)        64MB
//  8192* 8192       0~0x03ffffff(0 to 67,108,864-1)       256MB
// 16384*16384       0~0x0fffffff(0 to 268,435,456-1)      1024MB(1GB)
// Return value
//   Negative....Error(INITIALIZE_ERROR...Initialization error(failed to create an instance of the class: insufficient memory))
//   Blue noise sequence
typedef int (__stdcall* BLUENOISEEX)();
extern BLUENOISEEX bluenoiseex;
/////////////////////////
// Setting the folder for saving/loading blue noise matrices and the size of the matrix
// Not set for generating blue noise in the normal range (0~RAND_MAX)
// Set when there is a purpose to obtain a detailed blue noise using bluenoiseex()
// Input
//    const char*	pfolder;	Folder name where the matrix file exists/should be generated
//                              If it is NULL or "", use the built-in 256×256 matrix
//    int           size;		Matrix size (512/1024/2048/4096/8192/16384)
//                              In the case of 1024, generate a 1024×1024 blue noise matrix. File size is 4MB
// Return value
//   Negative....Error(INITIALIZE_ERROR...Initialization error(failed to create an instance of the class: insufficient memory))
//   Negative....Error(FILE_OPEN_ERROR....Cannot save or load)
//                (MEMORY_SHORTAGE....Insufficient memory)
// Read the file named sizexsizeraw.dat in the specified folder
//                   If size is 1024, the file name will be 1024x1024raw.dat
//                   If the file does not exist, create the file
//                   The larger the size, the higher-quality bluenoise is generated
typedef int (__stdcall* SETBLUENOISEMATRIX)(const char* pfolder,int size);
extern SETBLUENOISEMATRIX setbluenoisematrix;

The loading and freeing of DLLs are performed as follows:
#include "bluenoisecallback.h"
HINSTANCE bn_dllinstance;		// DLL instance
// DLL entry point
SBLUENOISE sbluenoise;
BLUENOISE bluenoise;
BLUENOISEEX bluenoiseex;
SETBLUENOISEMATRIX setbluenoisematrix;

{
    // ....
    // Loading
    // gmodulepath contains the path of the executable file
    // Assuming "bluenoisedll.dll" is in the path of the executable file
    char   filename[FILENAME_MAX];
    sprintf(filename, "%sbluenoisedll.dll", gmodulepath);
    bn_dllinstance = LoadLibrary(filename);
    if (bn_dllinstance == NULL) {
        char   buffer[512];
        sprintf(buffer, "Failed to load DLL file bluenoisedll.dll");
        AfxMessageBox(buffer, MB_OK | MB_ICONEXCLAMATION);
        return(2);
    }
    sbluenoise = (SBLUENOISE)GetProcAddress(bn_dllinstance, "sbluenoise");
    bluenoise = (BLUENOISE)GetProcAddress(bn_dllinstance, "bluenoise");
    bluenoiseex = (BLUENOISEEX)GetProcAddress(bn_dllinstance, "bluenoiseex");
    setbluenoisematrix = (SETBLUENOISEMATRIX)GetProcAddress(bn_dllinstance, "setbluenoisematrix");
    if (sbluenoise == NULL || bluenoise == NULL || bluenoiseex == NULL || setbluenoisematrix == NULL) {
        char   buffer[512];
        sprintf(buffer, "The version of DLL file bluenoisedll.dll is different");
        AfxMessageBox(buffer, MB_OK | MB_ICONEXCLAMATION);
        FreeLibrary(bn_dllinstance);
        return(2);
    }
    // ....
    // Freeing
    FreeLibrary(bn_dllinstance);
}
The calling of bluenoise() is performed as follows:
If calling bluenoiseex(), simply change "bluenoise" to "bluenoiseex" as shown below:
// Set bluenoise series to 1000 and display it in an edit box or other widgets
void CDlgBluenoise::OnBnClickedMakebluenoise100()
{
    m_editresult = "";
    char   buffer[1024];
    for (int i = 0; i < 1000; i++) {
        if (i % 10 == 0) {
            sprintf(buffer, "(%03d)", i / 10);
            m_editresult += buffer;
        }
        if (i % 10 == 9) {
            sprintf(buffer, "%10d\r\n", bluenoise());
        }
        else {
            sprintf(buffer, "%10d, ", bluenoise());
        }
        m_editresult += buffer;
    }
    UpdateData(FALSE);
}
The calling of setbluenoisematrix() is performed as follows:
// The folder is "g:/tmp/", but usually, set a different folder.
// m_editsize contains a value in the range of 512 to 16384.
void CDlgBluenoise::OnBnClickedSetsize()
{
    UpdateData(TRUE);
    if (m_editsize == 256) {
        setbluenoisematrix("", m_editsize);
    }
    else {
        setbluenoisematrix("g:\\tmp\\", m_editsize);
    }
    UpdateData(FALSE);
}