Hi
I got a bitmap picture i need to change it to black and white and then negative all colors in it ...
Can anybody gimme a clue ?
i assume you mean greyscale
Y = 0.587G + 0.299R + 0.114B
Y = luminance
set R, G, B all to the same Y value
to make it negative, 0FFh-Y
I posted code quite a long time ago to create a litho of an image, that is only black or white, no grey scale. I also posted greyscale code if you need it. You can find the code in my graphics library, only good for 32bit DIBs though. InvertImage might be what you want for your negative colors, its also in the lib.
Graphics.lib (http://www.quickersoft.com/donkey/files/Graphics.zip)
(source is included)
My mind stuck ...
i used graphic lib but when i translated it to masm my translated code didnt work ,then i found another example (http://www.masm32.com/board/index.php?topic=2640.0 ) but again when i added it to my application , its didnt grayed my bitmap.
I guess i have somekinda problem with bitmaps or converting my bitmap to a compatible bitmap for those exapmles.
i used bitblt for copying my bitmap to a bitmap that i prepared for those examples but destination bitmap was colorful lol
i put my code with explaining about what exactly i wanna do:
i got a bitmap that i print it , i want to print it in grayscale and negative colors then result would save inc and ganna be more beauty.
PrintStuff proc
LOCAL _di:DOCINFO
LOCAL p2:PRINTDLG
LOCAL p_dim:POINT
LOCAL p_dim2:POINT
LOCAL psd:PAGESETUPDLG
LOCAL sci:SCROLLINFO
LOCAL memdc :DWORD
LOCAL hbmp :DWORD
LOCAL xxWidth:DWORD
LOCAL bmp :BITMAP
invoke memfill, addr _di,sizeof DOCINFO,0
mov _di.cbSize,sizeof DOCINFO
mov _di.lpszDocName,eax
mov _di.lpszOutput,0
mov _di.lpszDatatype,0
mov _di.fwType,0
invoke memfill, addr p2,sizeof PRINTDLG-4,0
mov p2.lStructSize,sizeof PRINTDLG
mov p2.Flags,PD_RETURNDC or PD_USEDEVMODECOPIESANDCOLLATE
mov p2.nToPage,1000
mov p2.nMinPage,1
mov p2.nMaxPage,1000
invoke PrintDlg,addr p2
.if eax!=0
.if p2.hDC==0
invoke MessageBox,0,CADD("Printer DC is wrong"),0,0
.endif
invoke GetDeviceCaps,p2.hDC,HORZRES
mov p_dim.x,eax
invoke GetDeviceCaps,p2.hDC,VERTRES
mov p_dim.y,eax
invoke StartDoc,p2.hDC,addr _di
.if eax==SP_ERROR
invoke MessageBox,0,CADD("Cannot start, document"),0,0
.endif
invoke StartPage,p2.hDC
.if eax<=0
invoke MessageBox,0,CADD("Cannot start printer"),0,0
.endif
invoke CreateCompatibleDC,p2.hDC
mov memdc,eax
invoke CreateCompatibleBitmap,p2.hDC,p_dim.x,p_dim.y
mov hbmp,eax
invoke SelectObject,memdc,hbmp
push eax
invoke GetObject,hbmp,SIZEOF bmp,ADDR bmp
mov sci.cbSize,SIZEOF sci
mov sci.fMask,SIF_POS
invoke GetScrollInfo,hChild1,SB_VERT,ADDR sci
.if hReflex == 1
mov xxWidth,535
.else
mov xxWidth,423
.endif
invoke StretchBlt,memdc,0,0,bmp.bmWidth,bmp.bmHeight,hDrawDC,0,sci.nPos,xxWidth,663,SRCCOPY
invoke BitBlt,p2.hDC,0,15,bmp.bmWidth,bmp.bmHeight,memdc,0,0, SRCCOPY
pop eax
invoke SelectObject,memdc,eax
invoke DeleteDC,memdc
invoke DeleteObject,hbmp
;;;
invoke EndPage,p2.hDC
invoke EndDoc,p2.hDC
invoke DeleteDC,p2.hDC
.endif
ret
PrintStuff endp