Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
The Campus / Re: BITMAP STRUCT in win64.inc
« Last post by zedd151 on Today at 06:51:28 AM »
Hi zedd,

Thinking now about the structure :


The last DWORD entry is for the alignment.


Okay, I'll buy that.



Quote
The small name differences like mPlanes vs bmPlanes should not be a problem.


But for a conversion to 32 bits, the names would have to be changed then, as I have done to reflect the names in windows.inc. (32 bit)


Reference:


gdi BITMAP STRUCT
22
The Campus / Re: BITMAP STRUCT in win64.inc
« Last post by Vortex on Today at 06:45:20 AM »
Hi zedd,

Thinking now about the structure :

Code: [Select]
  BITMAP STRUCT
    bmType   LONG ?
    bmWidth   LONG ?
    bmHeight  LONG ?
    bmWidthBytes LONG ?
    mPlanes   WORD ?
    mBitsPixel  WORD ?
    DWORD ?
    mBits   LPVOID ?
  BITMAP ENDS

The last DWORD entry is for the alignment. The small name differences like mPlanes vs bmPlanes should not be a problem.
23
The Campus / BITMAP STRUCT in win64.inc
« Last post by zedd151 on Today at 06:38:39 AM »
While converting a program down to 32 bits, I noticed a potential flaw in win64.inc (as pointed out by Vortex)


The BITMAP structure in Windows.inc (32 bit) is defined as


Code: [Select]



BITMAP STRUCT
  bmType        DWORD       ?
  bmWidth       DWORD       ?
  bmHeight      DWORD       ?
  bmWidthBytes  DWORD       ?
  bmPlanes      WORD        ?
  bmBitsPixel   WORD        ?
  bmBits        DWORD       ?
BITMAP ENDS

in win64.inc:

Code: [Select]
  BITMAP STRUCT
    bmType   LONG ?
    bmWidth   LONG ?
    bmHeight  LONG ?
    bmWidthBytes LONG ?
    mPlanes   WORD ?   ;<-- error?
    mBitsPixel  WORD ? ;<-- error?
    DWORD ?                ;junction?
    mBits   LPVOID ?      ;<--error?
  BITMAP ENDS






24
The Workshop / Re: Microsoft MASM bug
« Last post by zedd151 on Today at 06:28:50 AM »
makteam provides a solution, too:




Interesting, but does it work?
25
The Workshop / Re: Screen Capture for 32 Bit machines
« Last post by Vortex on Today at 06:23:48 AM »
Hi zedd,

Thanks for your work. I will test it.
26
The Workshop / Screen Capture for 32 Bit machines
« Last post by zedd151 on Today at 06:14:37 AM »
I have with his permission, rewritten Vortex's screen capture routine(64 bit) for 32 bit usage. It is not a direct conversion of his program, just
what is necessary to capture the screen and output a bitmap file (in the location of the executable - for now)



This program is just the basics needed to capture the screen by simply clicking the executable. No Console Window, or window of any kind.
Later, I want to add code to let the program sit idly in the system tray until {PrtScr} or some other user definable key combinations are pressed.


Code: [Select]

; (semi)Original idea 'borrowed' from Vortex @ masm32.com
; Originally coded for 64 bit exe
; these are the basic bits and pieces to capture the complete window
; and save to a predetermined .bmp file
;--------------------------------------------------------------------------
;--------------------------------------------------------------------------
; Only need to use 'Assemble and Link' from the 'Project' menu, No Console
; Window is neded or desired
;--------------------------------------------------------------------------
;--------------------------------------------------------------------------
; 32 bit small version zedd151 @ masm32.com
;
; Will add code at some point to run the program in the background, awaiting
; the user pressing the 'PrtScr' key (or other key )


include \masm32\include\masm32rt.inc


.data


    hDC         dd 0    ; Device Context handle returned by GetDC
    hBmp        dd 0    ; Bitmap handle returned by CreateCompatibleBitmap
    hOld        dd 0    ; handle returned by SelectObject
    tempDC      dd 0    ; Device Context handle returned by CreateCompatibleDC
    xx          dd 0    ; screen width
    yy          dd 0    ; screen height
    Bits        dd 0    ; bits per pixel x number of color planes
    pMem        dd 0    ; ptr to allocated memory for saving the bitmap image
    hFile       dd 0    ; file handle to created bitmap file
    BmpSize     dd 0    ; size of bitmap data, not including headers
    SizeofDIB   dd 0    ; size of bitmap file, including headers
    BWritten    dd 0    ; pointer used as index for write file


    outfile     db "test.bmp", 0            ; output filename


align 16


    bm          BITMAP              <>      ; BITMAP structure
    BmpFileHdr  BITMAPFILEHEADER    <>      ; BITMAPFILEHEADER structure
    BmpInfoHdr  BITMAPINFOHEADER    <>      ; BITMAPINFOHEADER structure


BITMAP STRUCT
    bmType          DWORD   0   ; The bitmap type. This member must be zero.
    bmWidth         DWORD   0   ; The width, in pixels, of the bitmap. The width must be greater than zero.
    bmHeight        DWORD   0   ; The height, in pixels, of the bitmap. The height must be greater than zero.
    bmWidthBytes    DWORD   0   ; The number of bytes in each scan line. This value must be divisible by 2, ----
                                ; --- because the system assumes that the bit values of a bitmap form an array that is word aligned.
    bmPlanes        WORD    0   ; The count of color planes.
    bmBitsPixel     WORD    0   ; The number of bits required to indicate the color of a pixel.
    bmBits          DWORD   0   ; A pointer to the location of the (byte) values for the bitmap.
BITMAP ENDS


BITMAPFILEHEADER STRUCT
    bfType          WORD    0   ; The file type; must be BM.
    bfSize          DWORD   0   ; The size, in bytes, of the bitmap file.
    bfReserved1     WORD    0   ; Reserved; must be zero.
    bfReserved2     WORD    0   ; Reserved; must be zero.
    bfOffBits       DWORD   0   ; The offset, in bytes, from the beginning of the BITMAPFILEHEADER structure to the bitmap bits.
BITMAPFILEHEADER ENDS




BITMAPINFOHEADER STRUCT
    biSize          DWORD   0   ; Specifies the number of bytes required by the structure.
    biWidth         DWORD   0   ; Specifies the width of the bitmap, in pixels.
    biHeight        DWORD   0   ; Specifies the height of the bitmap, in pixels.
    biPlanes        WORD    0   ; Specifies the number of planes for the target device. This value must be set to 1.
    biBitCount      WORD    0   ; Specifies the number of bits per pixel (bpp).
    biCompression   DWORD   0   ; use BI_RGB for uncompressed RGB Bitmaps
    biSizeImage     DWORD   0   ; set to 0 for uncompressed RGB bitmaps.
    biXPelsPerMeter DWORD   0   ; set to 0
    biYPelsPerMeter DWORD   0   ; set to 0
    biClrUsed       DWORD   0   ; set to 0
    biClrImportant  DWORD   0   ; Specifies the number of color indices that are considered important for displaying the bitmap. ---
                                ; ----   If this value is zero, all colors are important.
BITMAPINFOHEADER ENDS




.code




start:


    lea     edi, bm


    invoke  GetDC, 0
    mov     hDC, eax
   
    invoke  CreateCompatibleDC, hDC
    mov     tempDC, eax


    invoke  GetSystemMetrics, SM_CXSCREEN
    mov     xx, eax
   
    invoke  GetSystemMetrics, SM_CYSCREEN
    mov     yy, eax
   
    invoke  CreateCompatibleBitmap, hDC, xx, yy
    mov     hBmp, eax
   
    invoke  SelectObject, tempDC, hBmp
    mov     hOld, eax


    invoke  BitBlt, tempDC, 0, 0, xx, yy, hDC, 0, 0, SRCCOPY






    invoke  GetObject, hBmp, sizeof(BITMAP), edi


    mov     BITMAP.bmBitsPixel[edi], 24


    xor     edx, edx
    movzx   eax, BITMAP.bmPlanes[edi]
    mul     BITMAP.bmBitsPixel[edi]
    mov     Bits, eax


    lea     ecx, BmpInfoHdr


    mov     BITMAPINFOHEADER.biSize[ecx], sizeof(BITMAPINFOHEADER)


    mov     eax, xx
    mov     BITMAPINFOHEADER.biWidth[ecx],eax


    mov     eax, yy
    mov     BITMAPINFOHEADER.biHeight[ecx],eax
   
    mov     ax,BITMAP.bmPlanes[edi]
    mov     BITMAPINFOHEADER.biPlanes[ecx],ax


    mov     ax,BITMAP.bmBitsPixel[edi]
    mov     BITMAPINFOHEADER.biBitCount[ecx],ax


    mov     BITMAPINFOHEADER.biCompression[ecx], BI_RGB
    xor     eax, eax
    mov     BITMAPINFOHEADER.biSizeImage[ecx], eax
    mov     BITMAPINFOHEADER.biXPelsPerMeter[ecx], eax
    mov     BITMAPINFOHEADER.biYPelsPerMeter[ecx], eax 
    mov     BITMAPINFOHEADER.biClrUsed[ecx], eax
    mov     BITMAPINFOHEADER.biClrImportant[ecx], eax


    xor     edx, edx
    mov     eax, BITMAP.bmWidth[ecx]


 
    mul     Bits
    add     eax, 31
    and     eax, -32
    shr     eax, 3
    mul     BITMAP.bmHeight[ecx]
    mov     BmpSize, eax


    invoke  VirtualAlloc, 0, eax, MEM_COMMIT, PAGE_READWRITE


    mov     pMem, eax


    invoke  GetDIBits, tempDC, hBmp, 0, dword PTR BITMAP.bmHeight[edi], pMem, ADDR BmpInfoHdr, DIB_RGB_COLORS


    xor     eax,eax
    invoke  CreateFile, addr outfile, GENERIC_WRITE, eax, eax, CREATE_ALWAYS, eax, eax


    mov     hFile, eax


    mov     eax, BmpSize
   
    add     eax, sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)


    mov     SizeofDIB, eax


    lea     edx, BmpFileHdr
    mov     BITMAPFILEHEADER.bfOffBits[edx], sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)


    mov     eax, SizeofDIB
    mov     BITMAPFILEHEADER.bfSize[edx], eax


    mov     BITMAPFILEHEADER.bfReserved1[edx], 0
    mov     BITMAPFILEHEADER.bfReserved2[edx], 0


    mov     BITMAPFILEHEADER.bfType[edx], 'MB'


    lea     esi, BWritten
   
    invoke  WriteFile, hFile, ADDR BmpFileHdr, sizeof(BITMAPFILEHEADER), esi, 0
           
    invoke  WriteFile,hFile, ADDR BmpInfoHdr, sizeof(BITMAPINFOHEADER), esi, 0
           
    invoke  WriteFile, hFile, pMem, BmpSize, esi, 0


    invoke  CloseHandle, hFile


    invoke  VirtualFree, pMem, 0, MEM_RELEASE   
     
    invoke  SelectObject, tempDC, hOld
    invoke  DeleteObject, hBmp
    invoke  DeleteDC, tempDC
    invoke  ReleaseDC, 0, hDC


    invoke  ExitProcess, 0
end start




If you do make some screen captures and want to post them, please use an external hosting site. hutch-- has indicated his concern over disk space usage and too many image uploads to the site. I use DropBox myself.  When linking an image or other link from DropBox, the link ends with "dl=0" you have to manually change to "dl=1" for the direct link to work properly.   8)




ScrCap(x86) Download
27
MasmBasic & the RichMasm IDE / Re: Miscellaneous snippets
« Last post by jj2007 on Today at 04:53:05 AM »
Your analysis is absolutely correct: XP behaves like that. Those resizing attempts that actually move the window trigger the resizing of the image. All others don't. But I would have to dig deep into the code to find a workaround, and I am not sure if XP is important enough to justify that effort :icon_mrgreen:
28
MasmBasic & the RichMasm IDE / Re: Miscellaneous snippets
« Last post by FORTRANS on Today at 04:42:33 AM »
Hi Jochen,

   Okay, how about:

Upper left  Resize
Top         Resize
Upper right Resize
Right       Crop
Lower right Crop
Bottom      Crop
Lower left  Resize
Left        Resize
Cropped to maximize, Resize
Maximum to restore, Resize


   More useful I hope?  Or am I still missing things as usual?

Regards,

Steve N.
29
The Workshop / Re: Microsoft MASM bug
« Last post by jj2007 on Today at 04:14:36 AM »
makteam provides a solution, too:
Quote
One potential workaround is to insert a nop before the .endif:

.if sbyte ptr al >= "a"
sub al, 20h
if @Version ge 1400
nop
endif
;compat
.endif

(The nop gets consumed by the bug leaving only intended code.)
30
MasmBasic & the RichMasm IDE / Re: Miscellaneous snippets
« Last post by jj2007 on Today at 04:06:05 AM »
on Windows XP.  Seems to crop on resizing.... Is that what was wanted?

Steve,
No, not really, see reply #53+#54. It's limited to XP, though. Apparently one message is not being sent correctly in XP.
Pages: 1 2 [3] 4 5 ... 10