{"id":153,"date":"2007-05-12T16:18:05","date_gmt":"2007-05-12T14:18:05","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/bitmaps-create-a-monochrome-bitmap\/"},"modified":"2007-05-12T16:18:08","modified_gmt":"2007-05-12T14:18:08","slug":"bitmaps-create-a-monochrome-bitmap","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/bitmaps-create-a-monochrome-bitmap\/","title":{"rendered":"Bitmaps: Create a monochrome bitmap"},"content":{"rendered":"<p>This function creates a &#8216;grayed&#8217; out bitmap.<br \/>\nSimply pass it a bitmap and a outline color.<\/p>\n<p><!--more--><br \/>\n[code lang=&#8221;delphi&#8221;]function TForm1.CreateDisabledBitmap(FOriginal: TBitmap; OutlineColor: TColor): TBitmap;<br \/>\nconst<br \/>\n   ROP_DSPDxax = $00E20746;<br \/>\nvar<br \/>\n   MonoBmp: TBitmap;<br \/>\n   IRect: TRect;<br \/>\nbegin<br \/>\n   IRect := Rect(0, 0, FOriginal.Width, FOriginal.Height);<br \/>\n   Result := TBitmap.Create;<br \/>\n   try<br \/>\n      Result.Width := FOriginal.Width;<br \/>\n      Result.Height := FOriginal.Height;<br \/>\n      MonoBmp := TBitmap.Create;<br \/>\n      try<br \/>\n         with MonoBmp do begin<br \/>\n            Assign(FOriginal);<br \/>\n\t\t\t\t{$IFDEF S_D3}<br \/>\n            HandleType := bmDDB;<br \/>\n         \t{$ENDIF}<br \/>\n            Canvas.Brush.Color := clBlack;<br \/>\n            if Monochrome then begin<br \/>\n               Canvas.Font.Color := clWhite;<br \/>\n               Monochrome := False;<br \/>\n               Canvas.Brush.Color := clWhite;<br \/>\n            end;<br \/>\n            Monochrome := True;<br \/>\n         end;<br \/>\n         with Result.Canvas do begin<br \/>\n            Brush.Color := OutlineColor;<br \/>\n            FillRect(IRect);<br \/>\n            Brush.Color := clBtnHighlight;<br \/>\n            SetTextColor(Handle, clBlack);<br \/>\n            SetBkColor(Handle, clWhite);<br \/>\n            BitBlt(Handle, 1, 1, IRect.Right &#8211; IRect.Left, IRect.Bottom &#8211; IRect.Top, MonoBmp.Canvas.Handle, 0, 0, ROP_DSPDxax);<br \/>\n            Brush.Color := clBtnShadow;<br \/>\n            SetTextColor(Handle, clBlack);<br \/>\n            SetBkColor(Handle, clWhite);<br \/>\n            BitBlt(Handle, 0, 0, IRect.Right &#8211; IRect.Left, IRect.Bottom &#8211; IRect.Top, MonoBmp.Canvas.Handle, 0, 0, ROP_DSPDxax);<br \/>\n         end;<br \/>\n      finally<br \/>\n         MonoBmp.Free;<br \/>\n      end;<br \/>\n   except<br \/>\n      Result.Free;<br \/>\n      raise;<br \/>\n   end;<br \/>\nend;<br \/>\n[\/code]<br \/>\nAnd this is one way you can call it.<\/p>\n<p>[code lang=&#8221;delphi&#8221;]Image2.Picture.Bitmap := CreateDisabledBitmap(Image1.Picture.Bitmap, clBtnFace);<br \/>\n[\/code]<\/p>\n<p>[tags]Delphi, Graphic[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This function creates a &#8216;grayed&#8217; out bitmap. Simply pass it a bitmap and a outline color.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[75,101],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-2t","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/153"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=153"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/153\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}