Pereiti prie turinio

Gerai yra rasyti tokio tipo C++ koda?


Svečias Aliarth

Rekomenduojami pranešimai

Svečias Aliarth

Laba diena. Gerai yra rasyti tokio tipo C++ koda?

* http://alivat.com/IMAGE_HBITMAP_GET_PIXEL_COLOR.txt

https://stackoverflow.com/questions/70551392/good-to-write-c-in-this-type-of-code

// ============================== BEGIN
// IMAGE_HBITMAP_GET_PIXEL_COLOR 
// ============================== PUBLIC
// ============================== ABOUT
// Set pixel color for HBITMAP object.
// ============================== MINIMUM SUPPORT
// Windows_XP
// Windows_Server_2003
// ============================== REQUIRE DLL (1)
// Gdi32.dll
// ============================== REQUIRE LIBRARIES (1)
// Gdi32.lib
// ============================== REQUIRE INCLUDES (2)
#include <Windows.h>
#include <WinDef.h>
// ============================== USING FUNCTIONS (4)
// =============== SYSTEM
// CreateCompatibleDC() - wingdi.h (Windows.h) | Gdi32.lib | Gdi32.dll | Windows_2000_Professional, Windows_2000_Server
// SelectObject() - wingdi.h (Windows.h) | Gdi32.lib | Gdi32.dll | Windows_2000_Professional, Windows_2000_Server
// SetPixel() - wingdi.h (Windows.h) | Gdi32.lib | Gdi32.dll | Windows_2000_Professional, Windows_2000_Server
// DeleteDC() - wingdi.h (Windows.h) | Gdi32.lib | Gdi32.dll | Windows_2000_Professional, Windows_2000_Server
// ============================== USING DATA_TYPES (3)
// HBITMAP - WinDef.h
// COLORREF - Windef.h (Windows.h) | Windows_2000_Professional, Windows_2000_Server
// HDC - BaseTsd.h, WinDef.h, WinNT.h (windows.h) | Windows_XP, Windows_Server_2003
// ============================== USING CONSTANTS (0)
// ============================== USING VARIABLES (0)
// ============================== CODE
COLORREF image_hbitmap_get_pixel_color(HBITMAP image_hbitmap, int image_x, int image_y)
{
COLORREF pixel_color;

// ===== CREATE_HDC - BEGIN
// CreateCompatibleDC() - The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.
HDC image_hdc = CreateCompatibleDC(
NULL // hdc (HDC) - A handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the application's current screen.
);
 if (image_hdc == NULL)
 {
 // ERROR
 }
// ===== CREATE_HDC - END


// ===== HBITMAP_TO_HDC - BEGIN
// SelectObject() - The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type.
 if (SelectObject(
 image_hdc, // hdc (HDC) - A handle to the DC.
 
 // h (HGDIOBJ) - A handle to the object to be selected.
 // The specified object must have been created by using one of the following functions.
 // * Bitmap - CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection.
 // Bitmaps can only be selected into memory DC's. A single bitmap cannot be selected into more than one DC at the same time.
 // * Brush - CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush.
 // * Font - CreateFont, CreateFontIndirect.
 // * Pen - CreatePen, CreatePenIndirect.
 // * Region - CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect.
 image_hbitmap
 
 ) == NULL)
 {
 // ERROR
 }
// ===== HBITMAP_TO_HDC - END


// ===== HDC_GET_PIXEL - BEGIN
// The GetPixel function retrieves the red, green, blue (RGB) color value of the pixel at the specified coordinates.
pixel_color = GetPixel(
image_hdc, // hdc (HDC) - A handle to the device context.
image_x, // x (int) - The x-coordinate, in logical units, of the pixel to be examined.
image_y // y (int) - The y-coordinate, in logical units, of the pixel to be examined.
);
 if (pixel_color == 0xFFFFFFFF) // CLR_INVALID (0xFFFFFFFF)
 {
 //  ERROR
 }
// ===== HDC_GET_PIXEL - END


// The DeleteDC function deletes the specified device context (DC).
 if (DeleteDC(
 image_hdc // hdc (HDC) - A handle to the device context.
 ) == 0)
 {
 // ERROR
 }

return pixel_color;
}
// ============================== END
// IMAGE_HBITMAP_GET_PIXEL_COLOR 
// ==============================

 

carbon (1).png

Redagavo Aliarth
Nuoroda į pranešimą
Dalintis kituose puslapiuose
  • Svečias pakeitė pavadinimą į Gerai yra rasyti tokio tipo C++ koda?
Svečias Aliarth

Nesu tikras del tokio kodo rasymo sistemos - Bet kai randuosi C++ kosmoso labirinte, eina geriau suprast su kas per dalykai, kuriuos po to reikia, del nezinia ko perrasyt.

Redagavo Aliarth
Nuoroda į pranešimą
Dalintis kituose puslapiuose

Prisijunkite prie diskusijos

Jūs galite rašyti dabar, o registruotis vėliau. Jeigu turite paskyrą, prisijunkite dabar, kad rašytumėte iš savo paskyros.

Svečias
Parašykite atsakymą...

×   Įdėta kaip raiškusis tekstas.   Atkurti formatavimą

  Only 75 emoji are allowed.

×   Nuorodos turinys įdėtas automatiškai.   Rodyti kaip įprastą nuorodą

×   Jūsų anksčiau įrašytas turinys buvo atkurtas.   Išvalyti redaktorių

×   You cannot paste images directly. Upload or insert images from URL.

Įkraunama...
  • Dabar naršo   0 narių

    Nei vienas registruotas narys šiuo metu nežiūri šio puslapio.

×
×
  • Pasirinkite naujai kuriamo turinio tipą...