flat assembler
Message board for the users of flat assembler.
Index
> Windows > How to display an image? (gdi ddb dpi) Goto page 1, 2 Next |
Author |
|
vivik 27 Aug 2017, 15:02
I want to display an image.
I'm confused by device dependent bitmap and device independent bitmap. https://msdn.microsoft.com/en-us/library/dd183382(v=vs.85).aspx I'm confused by dpi avareness. https://blogs.windows.com/buildingapps/2017/05/19/improving-high-dpi-experience-gdi-based-desktop-apps/ >When used in multi-monitor configuration, off-screen content will not be updated when the application window is moved between displays with different DPIs. I'm confused by SetProcessDPIAware. https://stackoverflow.com/questions/11066255/dpi-awareness-is-really-needed https://msdn.microsoft.com/en-us/library/ms701681 My goal is a simple tga viewer, and just learning to do gui on windows in general. |
|||
27 Aug 2017, 15:02 |
|
vivik 27 Aug 2017, 15:46
https://msdn.microsoft.com/en-us/library/windows/desktop/dd144877(v=vs.85).aspx
GetDeviceCaps LOGPIXELSX >In a system with multiple display monitors, this value is the same for all monitors. What do they mean? How to get dpi for current monitor then? Also, if app is displayed on two monitors simultaniously (half on one monitor, half on another), does window receive two WM_PAINT? Because there should be a way to adapt, if two monitors have different dpi. |
|||
27 Aug 2017, 15:46 |
|
vivik 27 Aug 2017, 16:10
Are DDB always represented as RGB or RGBA internally? I guess they can be monochrome for printers, but I don't think monochrome monitors is a thing anymore.
|
|||
27 Aug 2017, 16:10 |
|
revolution 27 Aug 2017, 16:16
vivik wrote: Are DDB always represented as RGB or RGBA internally? I guess they can be monochrome for printers, but I don't think monochrome monitors is a thing anymore. |
|||
27 Aug 2017, 16:16 |
|
vivik 27 Aug 2017, 16:21
If target device is a monitor, shouldn't "device dependent" bitmap be the same or almost the same for most of modern monitors?
|
|||
27 Aug 2017, 16:21 |
|
revolution 27 Aug 2017, 16:32
vivik wrote: If target device is a monitor, shouldn't "device dependent" bitmap be the same or almost the same for most of modern monitors? Just use DIB like everyone else. They are usually easier to deal with and Windows knows how to use the GPU and/or hardware acceleration to convert it if it is needed when painting. |
|||
27 Aug 2017, 16:32 |
|
vivik 27 Aug 2017, 16:34
As it looks like now, to display a tga, I have to first inpack it into DIB, and then from that create DDB. Why can't I unpack to DDB directly. Can't really find what kind of format DDB will have.
|
|||
27 Aug 2017, 16:34 |
|
revolution 27 Aug 2017, 16:38
A DDB format is unknown until you run the code on a particular device. So for example you won't know what format you need for a printer device until you create a context and interact with the device driver.
|
|||
27 Aug 2017, 16:38 |
|
vivik 27 Aug 2017, 16:41
I don't care about printers atm, I'm asking about monitors.
Maybe I should learn DirectWrite. To just display an image, yeah. |
|||
27 Aug 2017, 16:41 |
|
revolution 27 Aug 2017, 16:44
It's the same for monitors though, a DDB format for a monitor is also unknown until you have the context and work with it.
|
|||
27 Aug 2017, 16:44 |
|
vivik 27 Aug 2017, 16:54
Hm, okay. Thanks for info. Time to write code then. I'll bump this thread when I'll get stuck.
It's probably possible to get DDB format once at startup, implement a speedy unpacking for the most likely variant, and also implement a fallback to the standard way if something is weird. I'll google it. |
|||
27 Aug 2017, 16:54 |
|
revolution 27 Aug 2017, 17:04
Unless you are expecting to convert thousands of images per second then I wonder if using the "standard" DIB is the way to go. In theory using DDBs means you need to write so many different variants of converters to match all the possible hardware formats that the code overhead it crazy. Using DIB will take advantage of the device drivers inbuilt rapid conversion to the actual output format, and using DDB means you would basically be duplicating this code yourself, but doing it with the CPU instead of the hardware silicon.
|
|||
27 Aug 2017, 17:04 |
|
vivik 28 Aug 2017, 05:19
I said I'd implement only two: the most common and the standard (os provided) one.
Strange how CreateDIBitmap creates DDB. Shouldn't it be called CreateDDBitmap? |
|||
28 Aug 2017, 05:19 |
|
vivik 28 Aug 2017, 05:35
https://msdn.microsoft.com/en-us/library/dd183371(v=vs.85).aspx
BITMAP WORD bmPlanes; The count of color planes. What the hell are planes? Each rgb BITMAP is three bitmaps following each other? |
|||
28 Aug 2017, 05:35 |
|
ProMiNick 28 Aug 2017, 06:59
planes for bitmap(DIB,DDB) can have only value 1 (default), or value 0 (mean that OS ignore it and OS will think here is 1 by default).
_________________ I don`t like to refer by "you" to one person. My soul requires acronim "thou" instead. |
|||
28 Aug 2017, 06:59 |
|
vivik 03 Sep 2017, 21:12
About "writing directly to DDB". It looks like windows just wouldn't give me access to that, no way to get a pointer to raw data. https://stackoverflow.com/questions/14207618/get-bytes-from-hbitmap , "if bitmap is not created by CreateDIBSection bitmap.bmBit pointer will be null". Plus I looked inside a real world gdi game, it just used DIB and BitBlt.
When do I need to use DDB then? I guess it's like uploading image to GPU, you can do that if you rarely change it? It's probably safe to forget it's existance. I just launched elona recently, it got some fancy effects in the main menu, like "cicles on water". Obliviously no gpu here. I wonder how to do this, I guess the same DIB and BitBlt. http://www.herdsoft.com/ti/davincie/imex3izm.htm |
|||
03 Sep 2017, 21:12 |
|
vivik 04 Sep 2017, 06:52
https://msdn.microsoft.com/en-us/library/windows/desktop/dn469266(v=vs.85).aspx
"Per monitor–DPI aware applications are a new class of applications in Windows 8.1." okay, so I can ignore that for now, good |
|||
04 Sep 2017, 06:52 |
|
pabloreda 04 Sep 2017, 11:23
I use this ruttines for display graphics in win,
https://github.com/phreda4/reda4/tree/master/r4asm r4fasm.asm is window mode r4fasmfull is full screen r4fasm64.asm is for 64bit mode, not well tested |
|||
04 Sep 2017, 11:23 |
|
vivik 05 Sep 2017, 06:35
@pabloreda
In this piece of code from r4fasm2.asm, there are multiple .fin labels. How does it know to jump to a correct one? Code: SYSFFIRST: ; ( "path" -- fdd ) push ebx ecx edx edi esi mov esi,_dir .bcpy: mov bl,[eax] or bl,bl jz .ends mov byte[esi],bl add eax,1 add esi,1 jmp .bcpy .ends: mov dword [esi],$002A2f2f invoke FindFirstFile,_dir,fdd mov [hfind],eax cmp eax,INVALID_HANDLE_VALUE je .nin mov eax,fdd jmp .fin .nin: xor eax,eax .fin: pop esi edi edx ecx ebx ret ;=============================================== SYSFNEXT: ; ( -- fdd/0) lea esi,[esi-4] mov [esi], eax push ebx ecx edx edi esi invoke FindNextFile,[hfind],fdd or eax,eax jz .nin mov eax,fdd jmp .fin .nin: invoke FindClose,[hfind] xor eax,eax .fin: pop esi edi edx ecx ebx ret |
|||
05 Sep 2017, 06:35 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.