News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GdipCloneBitmapAreaI return an error

Started by costy35, March 18, 2010, 11:50:00 AM

Previous topic - Next topic

costy35

I am new to this forum, I started to do experiments with GDI + libraries for the GDI functions, getdibits I understand how it works, that create a DC and then select a bitmap in the DC, but do not have to use createcompatiblebitmap, I'm confused, getpixel and setpixel are too slow, now studying gdiplus functions, hence http://www.forum.it-berater.org/index.php?topic=31.0, and he gives me error function GdipCloneBitmapAreaI
.Const

PixelFormatMax                      Equ 0FH


         GdiplusStartupInput Struct
                 GdiplusVersion dd ?
                 DebugEventCallback dd ?
                 SuppressBackgroundThread dd ?
                 SuppressExternalCodecs dd ?
         GdiplusStartupInput EndS
.Data?
      startup GdiplusStartupInput <>
      token DD ?
      rct RECT <>
      numew DB 255 Dup (?)
.Data
      ok DB "ok!", 0
      pGraphics DD 0
      graphics1 DD 0
      hnd DD 0
      pBitmap DD 0
      pClone DD 0
      nume1 DB "c:\poza.jpg", 0
      nume DB "c", 0, ":", 0, "\", 0, "a", 0, "l", 0, "b", 0, ".", 0, "b", 0, "m", 0, "p", 0, 0, 0
      imagen1 DD 0
      pixelcolor DD 0
      hdc DD 0
.Code

Window1Procedure Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   .If uMsg == WM_CREATE
         Invoke GetDlgItem, hWnd, IDC_WINDOW1_PICTURE1
         Mov hnd, Eax
         Invoke GetDC, hnd
         Mov hdc, Eax
   .ElseIf uMsg == WM_COMMAND
      .If wParam == IDC_WINDOW1_BUTTON1
         Mov startup.GdiplusVersion, 1
         Invoke   GdiplusStartup, Addr token, Addr startup, 0
         Invoke GdipCreateFromHDC, hdc, Addr pGraphics
         Invoke MultiByteToWideChar, CP_OEMCP, MB_PRECOMPOSED, Addr nume1, -1, Addr numew, 255
         Invoke GdipCreateBitmapFromFile, Addr numew, Addr pBitmap
         ;....................................................................
         Invoke GdipCloneBitmapAreaI, 0, 0, 10, 10, PixelFormatMax, pBitmap, Addr pClone
            .If !Eax
            Invoke MessageBox, 0, 0, 0, 0
            .EndIf
         Invoke GdipDrawImageI, pGraphics, pClone, 0, 0
         ;......................................................................
               Invoke GdipDisposeImage, pClone
               Invoke GdipDisposeImage, pBitmap
               Invoke GdipDeleteGraphics, pGraphics
               Invoke  GdiplusShutdown, token
     .EndIf
   .ElseIf uMsg == WM_CLOSE
      Invoke IsModal, hWnd
      .If Eax
         Invoke EndModal, hWnd, IDCANCEL
         Return TRUE
      .EndIf
   .EndIf
   Return FALSE
Window1Procedure EndP

if I use this ...works

Invoke GdipDrawImageI, pGraphics, pBitmap, 0, 0

but it... does not work

Invoke GdipDrawImageI, pGraphics, pClone, 0, 0

qWord

hi,
What are you tyring to do? - You want to load an Image and then get the pixels for further processing?
FPU in a trice: SmplMath
It's that simple!

costy35

my project is an interactive webcam,I posted here this program!
Yes. I tried getdibits, but is too slow.
What other solutions would be?


Mov bi.bmiHeader.biSize, SizeOf bi.bmiHeader
Mov Eax, nx
Mov bi.bmiHeader.biWidth, Eax
Mov Eax, ny
Mov bi.bmiHeader.biHeight, Eax
Mov bi.bmiHeader.biPlanes, 1
Mov bi.bmiHeader.biBitCount, 32
Mov bi.bmiHeader.biCompression, BI_RGB
Mov Eax, bufg
Mov bi.bmiHeader.biSizeImage, Eax
Mov bi.bmiHeader.biClrUsed, 0
Mov bi.bmiHeader.biClrImportant, 0

Invoke BitBlt, sr_kopya, 0, 0, nx, ny, sr, 0, 0, SRCCOPY
;Invoke BitBlt, hdc, 0, 0, nx, ny, sr_kopya, 0, 0, SRCCOPY
Invoke GetDIBits, sr_kopya, bmp_kopya, 0, ny, buf, Addr bi, NULL
;....................................................................
;;Mov [Ebx + 704], Eax
;Invoke SendDlgItemMessage, hWnd, IDC_WINDOW1_CHECK1, BM_GETCHECK, 0, 0
;Cmp Eax, BST_CHECKED
;Jz jos1
Mov Eax, 0FFFF20H
Mov Ebx, buf
Mov Edx, 15000
.Repeat
Mov Eax, [Ebx]
;..................................................
Cmp Al, 255
Jnz @F
Mov nrv, Edx
@@:

Add Ebx, 8
Dec Edx
.Until !Edx
;.....................................................
Invoke SetDIBits, sr_kopya, bmp_kopya, 0, ny, buf, Addr bi, 0
Invoke BitBlt, hdc, 0, 0, nx, ny, sr_kopya, 0, 0, SRCCOPY

qWord

costy35,
there some problems in your code:
- you are unloading DLLs before using the requested function
- the calculation of buffer is wrong
- your are using unicode functions with ANSI string (capCreateCaptureWindowW)

other thoughts
- capCreateCaptureWindow are declared in vfw32.inc (+ vfw32.lib)
- windows timer resolution is about 10~15ms.
- look for WM_CAP_SET_CALLBACK_VIDEOSTREAM - seems an easy way to receive frames if the correct video format is set
- AFAIKS inpout32.dll requires hwinterface.sys to work






FPU in a trice: SmplMath
It's that simple!