Recent Posts

Pages: [1] 2 3 ... 10
1
The concept / D2D "Circular text"
« Last post by Patrice Terrier on April 14, 2024, 06:38:01 pm »
As a matter of comparison here is the code to draw a circular text using the D2D API

Code: [Select]
#include <windows.h>
#include <d2d1.h>
#include <dwrite.h>
#include <cmath>

#pragma comment(lib, "d2d1.lib")
#pragma comment(lib, "dwrite.lib")

constexpr auto IDI_ICON1     = 101;

// Global pointers for Direct2D and DirectWrite interfaces
ID2D1Factory* pD2DFactory = nullptr;
ID2D1HwndRenderTarget* pRenderTarget = nullptr;
ID2D1SolidColorBrush* pBrush = nullptr;
IDWriteFactory* pDWriteFactory = nullptr;
IDWriteTextFormat* pTextFormat = nullptr;

static void Initialize() {
    D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &pD2DFactory);
    DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&pDWriteFactory));
}

static void CreateGraphicsResources(HWND hwnd) {
    if (!pRenderTarget) {
        RECT rc;
        GetClientRect(hwnd, &rc);
        D2D1_SIZE_U size = D2D1::SizeU(rc.right, rc.bottom);
        pD2DFactory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(), D2D1::HwndRenderTargetProperties(hwnd, size), &pRenderTarget);

        pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(0xFF037BFA), &pBrush);

        pDWriteFactory->CreateTextFormat(
            L"Segoe GUI emoji",
            nullptr,
            DWRITE_FONT_WEIGHT_BOLD,
            DWRITE_FONT_STYLE_NORMAL,
            DWRITE_FONT_STRETCH_NORMAL,
            50.0f,
            L"", //locale
            &pTextFormat
        );

        pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
        pTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
    }
}

static void DiscardGraphicsResources() {
    if (pBrush) pBrush->Release();
    if (pRenderTarget) pRenderTarget->Release();
    if (pTextFormat) pTextFormat->Release();
    pBrush = nullptr;
    pRenderTarget = nullptr;
    pTextFormat = nullptr;
}

static void OnPaint(HWND hwnd) {
    PAINTSTRUCT ps;
    BeginPaint(hwnd, &ps);
    CreateGraphicsResources(hwnd);
    pRenderTarget->BeginDraw();
    pRenderTarget->Clear(D2D1::ColorF(D2D1::ColorF::White));
    D2D1_SIZE_F size = pRenderTarget->GetSize();

    const WCHAR* text = L"This is a Circular text using the D2D API.";
    const float radius = 200.0f;
    const D2D1_POINT_2F center = D2D1::Point2F(size.width / 2, size.height / 2);
    const size_t length = wcslen(text);
    const float angleStep = 360.0f / static_cast<float>(length);

    for (size_t i = 0; i < length; ++i) {
        WCHAR letter[2] = { text[i], 0 };

        float angle = DegreesToRadians(angleStep * i);
        D2D1_POINT_2F position = {
            center.x + cos(angle) * radius,
            center.y + sin(angle) * radius
        };

        D2D1_MATRIX_3X2_F rotation = D2D1::Matrix3x2F::Rotation(angleStep * i + 90, position);
        pRenderTarget->SetTransform(rotation);

        pRenderTarget->DrawText(
            letter,
            ARRAYSIZE(letter),
            pTextFormat,
            D2D1::RectF(position.x - 20, position.y - 20, position.x + 20, position.y + 20),
            pBrush
        );

        pRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity());
    }

    HRESULT hr = pRenderTarget->EndDraw();
    if (FAILED(hr) || hr == D2DERR_RECREATE_TARGET) {
        DiscardGraphicsResources();
    }
    EndPaint(hwnd, &ps);
}

static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    switch (uMsg) {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;

        case WM_PAINT:
            OnPaint(hwnd);
            return 0;
    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) {
    Initialize();

    // Register the window class
    const wchar_t CLASS_NAME[] = L"Sample Window Class";
    WNDCLASS wc = {};
    wc.lpfnWndProc = WindowProc;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
    wc.lpszClassName = CLASS_NAME;

    RegisterClass(&wc);

    // Create the window
    HWND hwnd = CreateWindowEx(
        0,
        CLASS_NAME,
        L"Circular Text with Direct2D",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, 600, 600,
        nullptr,
        nullptr,
        hInstance,
        nullptr
    );

    if (hwnd == nullptr) {
        return 0;
    }

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);

    // Run the message loop
    MSG msg = {};
    while (GetMessage(&msg, nullptr, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    DiscardGraphicsResources();
    if (pD2DFactory) pD2DFactory->Release();
    if (pDWriteFactory) pDWriteFactory->Release();

    return 0;
}
2
The concept / Tutor_19 "Circular text" (C++ VS2022 GDImage64 tutorial)
« Last post by Patrice Terrier on April 13, 2024, 07:32:58 pm »
About Tutor_19
Its purpose is to create one single or multiple circular text objects to use for logo or animaion.

It uses a new API named ZD_CreateCircularTextBitmap
using 7 parameters:
WCHAR* zText, the unicode string to create the circular text from.
WCHAR* zFont, the unicode string for the font to use (could be a .ttf private font).
long fontSize, the font size height.
long fontSyle, for example FontStyleBold.
long radius, the inner radius of the circular text.
DWORD ColrARGB, the ARGB color to use.
float step, the distance between each character.

The function returns a BITMAP handle that can be used by the ZD_DrawBitmapToCtrl API.

The AngleRotation procedure is using direct call to the GDIPLUS FLAT API to compute the correct rotation angle.

The window itself works in DWM transparent composited mode using the GDImage ZI_DwmEnable API.




3
The concept / Re: Tutor_06 (updated)
« Last post by Patrice Terrier on March 13, 2024, 01:19:45 pm »
Tutor_06,
has been updated to use the latest GDImage64.dll and WinLIFT64.dll, now with Y slider (like in the 32-bit version).
4
64-bit SDK programming / Webp
« Last post by Patrice Terrier on February 27, 2024, 09:45:02 am »
WebP is a raster graphics file format developed by Google intended as a replacement for JPEG, PNG, and GIF file formats. It supports both lossy and lossless compression, as well as animation and alpha transparency.

The attached C++ VS2022 SDK style source code project is able to convert .webp to .png using direct call to the gdiplus flat API.

The project is provided with a webp image created with the help of AI (ChatGPT 4).

It is a complement to the webm project posted here.
5
The concept / VIDEO
« Last post by Patrice Terrier on February 13, 2024, 07:02:20 pm »
Here is a video created by Graham McPhee about using WinLIFT 7.00 32-bit with PowerBASIC.

YouTube Video is here
6
The concept / SkinTheme
« Last post by Patrice Terrier on February 13, 2024, 06:40:35 pm »
Here is a new demo named SkinTheme.

It is provided with several exclusive images (created with the help of AI) stored in the \Background folder.
And 4 skin themes:
Busi.sks
Leopard.sks
RainbowDark.sks
Sony.sks


I did put the a copy of the 32 and 64-bit binary EXE for comparison purpose.
Skintheme32.exe (32 Kb) is written in PowerBASIC
Skintheme64.exe (15 Kb) is written in C++
Both are using the same low level procedural SDK syntax, that is the only common denominator to all the Windows languages.

You can change the wallpaper background using left or right mouse click on the top left icon.
You can change the skin theme using the multmedia arrows below the (help) button.

If you plan to use WinLIFT and the exclusive skin theme in your own projets,
consider making a donation.
7
The concept / WinLIFT32.dll new version
« Last post by Patrice Terrier on February 08, 2024, 01:21:58 pm »
This new version is intended to be used by those using the (paypal) donate-ware version.

It is now able to use composited skin theme.

As an extra bonus the composited RainbowDark theme is provided together with the attached .7z file.



This theme is also available in light mode.

8
The concept / Re: WinLIFT32.dll version 7.00
« Last post by Pierre Bellisle on February 03, 2024, 11:48:48 pm »
Une semaine sans internet!
Comment fais-tu?

Et tu-es encore de ce monde!
Y-a pas à dire, un dur à cuire.
Bob Morane dans l'âme.
Lino Ventura gonflé à bloc.
Résiste...

De mon coté, j'ai tout mon temps.
Prend soin de ta bien aimée et profite du temps qui passe.
Une pizza du Laca et une nuit étoilées, ce n'est pas moche...

Merci encore pour tout.
9
The concept / Re: WinLIFT32.dll version 7.00
« Last post by Patrice Terrier on February 03, 2024, 08:03:01 pm »
Pierre

J'ai un problème de connection (pas d'internet pendant une semaine, car le répartiteur qui dessert ma commune a été détruit par un accident). Je suis obligé d'utiliser le téléphone de mon épouse pour poster ce message. J'essaierai de me procurer une Airbox 4- 4G, mais elle sont en rupture car tout le monde dans ma commune en veut une.

Dès que je peux, je te prépare un zip avec la version destinée aux utilisateurs de la version donate-ware. J'enverrai les informations de téléchargement sur ta boite mail si elle est toujours valide.

PS Le fichier .chm en ta possession est toujours valide, les nouvelles fonctions sont documentées ici
http://www.objreader.com/index.php?topic=434.msg6504#msg6504

10
The concept / Re: WinLIFT32.dll version 7.00
« Last post by Pierre Bellisle on February 03, 2024, 05:01:32 am »
Salut Pat,
J'ai le fichier d'aide 4.87, y a-t-il plus récent?
En ce qui concerne les peaux, sont-elle disponible?

Mille mercis, quel travail fantastique...

-

Hi Pat,
I got the v. 4.87 help file, is there something newer?
About the skins, are they available?

Thousand thanks, what a fantastic work...

Pages: [1] 2 3 ... 10