Author Topic: To Domenico Labate  (Read 644 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1780
    • zapsolution
To Domenico Labate
« on: December 16, 2019, 06:40:26 pm »
Domenico

Here is the ZIP file of the GDImage.chm file, this is an old one written for the GDImage version 5.00, but still accurate for most of the basic API.
Patrice
(Always working with the latest Windows version available...)

Domenico Labate

  • Newbie
  • *
  • Posts: 3
Re: To Domenico Labate
« Reply #1 on: December 16, 2019, 09:01:49 pm »
Hi Patrice,
Thank you very much for your generous availability!
Kindly greetings
Domenico

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1780
    • zapsolution
Re: To Domenico Labate
« Reply #2 on: December 16, 2019, 09:55:09 pm »
Domenico

You must download Visual Studio Community that is free, currently version 2019.

I am using it since version 2005.
GDImage and WinLIFT are still compiled with VS version 2010 (to produce smaller binary files).

I have installed version 2019, but so far i keep using version 2017 (for stability purpose).

Once installed you can select the language of your choice, but i recommend to use the English package, because that's our working language here. ;)

« Last Edit: December 17, 2019, 08:47:36 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Domenico Labate

  • Newbie
  • *
  • Posts: 3
Re: To Domenico Labate
« Reply #3 on: April 01, 2020, 08:35:48 am »
Bonjour Patrice!
I have studied a lot in this period but I have not been able to solve the problem. It is not easy to switch from PB to C ++, as you have wisely indicated. Windows under the bodywork is very powerful but it is not easy to master it. Especially for me who have always worked with character interface. Now, I'm in a difficult situation. Since I absolutely cannot tell my daughter that I cannot complete the project, I have to produce something that at least gives a glimpse of the path to follow. Moving over time the construction of a better and more efficient model. I have the temporary advantage of the povemic for covid-19 which leaves universities closed but sooner or later the universities will reopen. What I want to do now is to write the module that reconstructs the movement performed by a person by analyzing a script saved in an image. For this reason, I asked for an example in pbcc sdk to begin to see if the various algorithms can result to some extent (50%, 60%, 70%, or more). I studied various books of manipulation and analysis of the position of the pixels in two-dimensional plane. But it is difficult to implement them in a language that is not part of me. Now in order not to distract you from your things, I wanted to ask you if you have a simple example (in pbcc 5 or 6) of reading from an image file, in order to examine the dispositions of the pixels represented in the two-dimensional plane. And how do you read the individual pixels through your GDImage. I'm pretty motivated but I need to use something familiar. I am sure you understand my mood and I am confident that you will be in excellent health despite what is happening outside our homes but close to us. Thanks, as always, for your time.
See you soon
Domenico
Domenico

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1780
    • zapsolution
Re: To Domenico Labate
« Reply #4 on: April 01, 2020, 05:08:04 pm »
Domenico

here is the core zGetDIBits API used to fulfill an array in both PB and C++

PB
Code: [Select]
FUNCTION zGetDIBits ALIAS "zGetDIBits" (BYVAL hBitmap AS LONG, PixelArray() AS LONG) EXPORT AS LONG
    LOCAL bi AS MYBITMAPINFO
    LOCAL bm AS BITMAP
    LOCAL dwp AS DWORD PTR
    LOCAL hIC, hDC AS LONG
    IF hBitmap THEN
       hIC = zDisplayDC()
       hDC = CreateCompatibleDC(hIC)
       SelectObject(hDC, hBitmap)

       GetObject(hBitmap, SIZEOF(bm), bm)
       bi.bmiHeader.biSize        = SIZEOF(bi.bmiHeader)
       bi.bmiHeader.biWidth       = bm.bmWidth
       bi.bmiHeader.biHeight      = -bm.bmHeight ' Put top in TOP instead of bottom!
       bi.bmiHeader.biPlanes      = 1
       bi.bmiHeader.biBitCount    = 32
       bi.bmiHeader.biCompression = %BI_RGB
       REDIM PixelArray(bm.bmWidth - 1, bm.bmHeight - 1) AS LONG
       dwp = VARPTR(PixelArray(0,0))
       FUNCTION = GetDIBits(hDC, hBitmap, 0, bm.bmHeight, BYVAL dwp, bi, %DIB_RGB_COLORS)

       DeleteDC(hIC)
       DeleteDC(hDC)

    END IF
END FUNCTION

C++
Code: [Select]
long zGetDIBits (IN HBITMAP hBitmap, LPVOID lpArray) { // dllexport AS LONG
    long nRet = 0;
    if ((hBitmap) && (lpArray)) {
       HDC hIC = zDisplayDC();
       HDC hDC = CreateCompatibleDC(hIC);
       SelectObject(hDC, hBitmap);
       BITMAP bm;
       GetObject(hBitmap, sizeof(bm), &bm);
       BITMAPINFO bi;
       bi.bmiHeader.biSize        = sizeof(bi.bmiHeader);
       bi.bmiHeader.biWidth       = bm.bmWidth;
       bi.bmiHeader.biHeight      = -bm.bmHeight; // Put top in TOP instead of bottom!
       bi.bmiHeader.biPlanes      = 1;
       bi.bmiHeader.biBitCount    = 32;
       bi.bmiHeader.biCompression = BI_RGB;
       //REDIM PixelArray(bm.bmWidth, bm.bmHeight) AS LONG
       //LOCAL dwp AS DWORD PTR
       //lpArray = VARPTR(PixelArray(0,0))
       nRet = GetDIBits(hDC, hBitmap, 0, bm.bmHeight, lpArray, &bi, DIB_RGB_COLORS);
       DeleteDC(hIC);
       DeleteDC(hDC);
    }
    return nRet;
}

You can see how close they are.

Note: It is better to use a static array matching the size of the bitmap.

But you can also work directly with bit rather than long (4-bit), and then no need to pass an array, like in this code

Code: [Select]
    long nStep = bm.bmBitsPixel / 8;
    long x, y, w, h;
    BYTE* pBits = (BYTE*) bm.bmBits;
    w = bm.bmWidth;  // width
    h = bm.bmHeight; // height
    for (y = 0; y < h; y++) {
        for (x = 0; x < w; x++) {

             // Here you can manipulate the bits
             pBits[3] = A; // alpha
             pBits[2] = R; // red
             pBits[1] = G; // green
             pBits[0] = B; // blue

            pBits += nStep;
        }
    }

There is an example of bit manipulation in the attached resource.bas example, search for CASE %ID_MOVE_ZMAGIC.
To see it in action press the button named "Show Bitmap Overlay", this is an old example but still accurate ;)
« Last Edit: April 01, 2020, 05:50:26 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Domenico Labate

  • Newbie
  • *
  • Posts: 3
Re: To Domenico Labate
« Reply #5 on: April 01, 2020, 08:40:21 pm »
Hi Patrice,
I believe that now, thanks to your great help, I can put myself in working hard to overcome my limits and arrive at a promising result useful to convince the thesis supervisor and proceed towards the preparatory phase for my daughter's doctoral research. I don't have a word now to say thank you. But I promise, as a gentleman as you are too, that I will do something to show my gratitude and esteem to the man Patrice Terrier. To the programmer, designer, planner and creator of spectacular graphic elaborations I can only say that I am happy and lucky to have known a great and talented code writer. Later on I will ask you if between the code you have written in the past there is something about how to distribute the load of my brute force algorithms that work on the graphs[1] of the possible paths on the CPU or GPU cores. Now I will try to understand how your precious and fundamental example works.
Thanks a lot Patrice and and best wishes for a peaceful period of Holy Easter!

Grazie infinite, domenico

[1] From graph theory, mathematical structures used to model pairwise relations between objects
« Last Edit: April 01, 2020, 08:46:56 pm by Domenico Labate »