Basically I need help saving a BMP.
LOCAL Buffer1 [1000]:BYTE ;local buffer
LOCAL lpBuffer1:DWORD
LOCAL bmi:BITMAPINFO
LOCAL bmih:BITMAPINFOHEADER
LOCAL hDC:DWORD
LOCAL imageDC:DWORD
LOCAL hbitmap:DWORD
;Define a BITMAPINFO and fill it
LEA eax,DWORD PTR bmi
mov edi,eax
assume edi:ptr BITMAPINFO
mov [edi].bmiHeader.biSize,SIZEOF BITMAPINFOHEADER
mov [edi].bmiHeader.biWidth,1728
mov [edi].bmiHeader.biHeight,-2290
mov [edi].bmiHeader.biPlanes,1
mov [edi].bmiHeader.biBitCount,1
mov [edi].bmiColors[1].rgbBlue,0FFh
mov [edi].bmiColors[1].rgbGreen,0FFh
mov [edi].bmiColors[1].rgbRed,0FFh
assume edi:nothing
;Create DC compatible with the monitor as null
invoke CreateCompatibleDC,0
mov hDC,eax
;Create DIB
invoke CreateDIBSection,hDC,ADDR bmi,DIB_RGB_COLORS,pvBits,0,0 ;so you have a B/W DIB section
mov hbitmap,eax
invoke SelectObject,hDC,hbitmap
mov oldbitmap,eax ;to delete this object later
invoke PatBlt,hDC,0,0,1728,2290,WHITENESS
invoke SetTextAlign,hDC,TA_UPDATECP
invoke lstrlen,lpBuffer1
invoke TextOut,hDC,0,0,lpBuffer1,eax ;to write on the BMP
;NOW HOW DO I SAVE THE BMP FROM THE hDC I CREATED??????????????????????
Search the forum for GetDiBits. I am pretty sure there are plenty of examples around.
I think GetDIBbits requires the source to be a DDB not a DIB.?
Quote from: jklosak on December 08, 2009, 09:58:46 PM
I think GetDIBbits requires the source to be a DDB not a DIB.?
You are right. I did that stuff years ago in 16-bit Windows, and don't remember all the details. Look at this page (http://www.codeguru.com/forum/showthread.php?t=412541), and search in the page for Bingo.
????????? Bingo????????????????? 100s of pages. none helpful. :(
I wrote search
in the page for Bingo:
QuoteBingo: now I can throw away all the device contexts and access the bits of the DIBSection directly.
However I had the gut feeling that this was rather long-winded. Obviously GetDIBits was the slow bit, as that's where the conversion has to occur (since there is no guarantee that the CompatibleDC is in the same format as my DIBSection).
Now, as per your suggestion, I tried the much simpler approach of:
Code:
CreateDC (screen)
CreateCompatibleDC
CreateDIBSection
Select DIBSection into CompatibleDC
BitBlt from screen to CompatibleDC (thereby 'painting' the DIBSection)
This seems to work a treat -- great.
wow :( you just made another DIB........
maybe someone else has a fresh approach to saving a BMP to file from a DIB.
I would love some help with this. Not fairy tales from Italy. I need to access the bytes from a DIB and save them as a BMP as I initialy outlined. any real help much appreciated.
QuoteI would love some help with this. Not fairy tales from Italy.
I think that was a fairly rude statement, considering he was just trying to help you.
I think a reading of the forum rules would be helpful, especially #4:
Quote4. There will be no abuse or insults towards other members......
Have you tried GDI+ functions? A couple to look at would be GdipCreateFromHBITMAP and GdipSaveImageToFile.
I have tried GDI fuctions for the last 48 hours with little success. I need the bits of the DIB.
This MSDN page has some code that saves to a file - Capturing an Image (http://msdn.microsoft.com/en-us/library/dd183402(VS.85).aspx)
Quote from: sinsi on December 09, 2009, 02:45:31 AM
This MSDN page has some code that saves to a file - Capturing an Image (http://msdn.microsoft.com/en-us/library/dd183402(VS.85).aspx)
Attention, Sinsi, that link contains a call to GetDIBits. Given your photo, you risk another WOW WOW from our friendly new member :green
We could have given him a link to this post (http://www.masm32.com/board/index.php?topic=10850.msg82557#msg82557), but I don't think that JimG would be happy to answer... ::)
Quote from: jj2007 on December 09, 2009, 07:17:27 AM
Quote from: sinsi on December 09, 2009, 02:45:31 AM
This MSDN page has some code that saves to a file - Capturing an Image (http://msdn.microsoft.com/en-us/library/dd183402(VS.85).aspx)
Attention, Sinsi, that link contains a call to GetDIBits. Given your photo, you risk another WOW WOW from our friendly new member :green
We could have given him a link to this post (http://www.masm32.com/board/index.php?topic=10850.msg82557#msg82557), but I don't think that JimG would be happy to answer... ::)
QuoteA nod is as good as a wink to a blind horse
:wink
Quote from: rags on December 09, 2009, 01:49:30 AM
QuoteI would love some help with this. Not fairy tales from Italy.
I think that was a fairly rude statement, considering he was just trying to help you.
I disagree. This little clap on JJ's head was well deserved. "Good intentions" is no excuse at all, given that a considerable amount of the evil things happening on earth is done by people with "good intentions".
Thanks for all the suggestions. I will keep working on this the next couple days. I know it is doable and these pointers should help get it done.
Have a nice Holiday.
jjk