{"id":381,"date":"2010-04-02T00:23:13","date_gmt":"2010-04-02T03:23:13","guid":{"rendered":"http:\/\/leandroascierto.com\/blog\/?p=381"},"modified":"2011-08-27T08:09:28","modified_gmt":"2011-08-27T11:09:28","slug":"fillrectplus","status":"publish","type":"post","link":"https:\/\/leandroascierto.com\/blog\/fillrectplus\/","title":{"rendered":"FillRectPlus"},"content":{"rendered":"<p style=\"text-align: justify;\">Esta funci\u00f3n la misma pero utilizando GDI Plus con m\u00e1s opciones, es muy \u00fatil a hora de trabajar con gr\u00e1ficos ya que se gana mucha velocidad.<\/p>\n<p align=\"center\">\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"http:\/\/www.leandroascierto.com\/blog\/imagenes\/FillRectPlus.png\" alt=\"FillRectPlus.png\" width=\"394\" height=\"299\" \/><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n\r\nOption Explicit\r\n'------------------------------------------------------\r\n'Autor: Leandro Ascierto\r\n'Web:   www.leandroascierto.com.ar\r\n'Fecha  02\/04\/2010\r\n'------------------------------------------------------\r\nPrivate Declare Function GdipCreateFromHDC Lib &quot;gdiplus&quot; (ByVal hdc As Long, ByRef graphics As Long) As Long\r\nPrivate Declare Function GdipDeleteGraphics Lib &quot;gdiplus&quot; (ByVal graphics As Long) As Long\r\nPrivate Declare Function GdipLoadImageFromFile Lib &quot;gdiplus&quot; (ByVal FileName As Long, ByRef image As Long) As Long\r\nPrivate Declare Function GdiplusStartup Lib &quot;gdiplus&quot; (ByRef token As Long, ByRef lpInput As GDIPlusStartupInput, Optional ByRef lpOutput As Any) As Long\r\nPrivate Declare Function GdiplusShutdown Lib &quot;gdiplus&quot; (ByVal token As Long) As Long\r\nPrivate Declare Function GdipDisposeImage Lib &quot;gdiplus&quot; (ByVal image As Long) As Long\r\nPrivate Declare Function GdipCreateTexture Lib &quot;GdiPlus.dll&quot; (ByVal mImage As Long, ByVal mWrapMode As WrapMode, ByRef mTexture As Long) As Long\r\nPrivate Declare Function GdipFillRectangle Lib &quot;GdiPlus.dll&quot; (ByVal mGraphics As Long, ByVal mBrush As Long, ByVal mX As Single, ByVal mY As Single, ByVal mWidth As Single, ByVal mHeight As Single) As Long\r\nPrivate Declare Function GdipDeleteBrush Lib &quot;GdiPlus.dll&quot; (ByVal mBrush As Long) As Long\r\nPrivate Declare Function GdipScaleTextureTransform Lib &quot;GdiPlus.dll&quot; (ByVal mBrush As Long, ByVal mSx As Single, ByVal mSy As Single, ByVal mOrder As Long) As Long\r\nPrivate Declare Function GdipTranslateTextureTransform Lib &quot;GdiPlus.dll&quot; (ByVal mBrush As Long, ByVal mDx As Single, ByVal mDy As Single, ByVal mOrder As Long) As Long\r\n \r\nPrivate Enum WrapMode\r\n    WrapModeTile = &amp;H0\r\n    WrapModeTileFlipX = &amp;H1\r\n    WrapModeTileFlipy = &amp;H2\r\n    WrapModeTileFlipXY = &amp;H3\r\n    WrapModeClamp = &amp;H4\r\nEnd Enum\r\n \r\nPrivate Type GDIPlusStartupInput\r\n    GdiPlusVersion                      As Long\r\n    DebugEventCallback                  As Long\r\n    SuppressBackgroundThread            As Long\r\n    SuppressExternalCodecs              As Long\r\nEnd Type\r\n \r\nPrivate Const GdiPlusVersion            As Long = 1&amp;\r\n \r\nDim GdipToken As Long\r\n \r\nPrivate Function FillRectPlus(ByVal hdc As Long, _\r\n                                ByVal hImage As Long, _\r\n                                ByVal x As Single, _\r\n                                ByVal y As Single, _\r\n                                ByVal Width As Single, _\r\n                                ByVal Height As Single, _\r\n                                Optional ByVal nScaleX As Single = 1, _\r\n                                Optional ByVal nScaleY As Single = 1, _\r\n                                Optional EnuWrapMode As WrapMode) As Boolean \r\n \r\n    Dim hGraphics As Long\r\n    Dim hBrush As Long\r\n \r\n    If GdipCreateFromHDC(Me.hdc, hGraphics) = 0 Then \r\n        If GdipCreateTexture(hImage, EnuWrapMode, hBrush) = 0 Then \r\n            Call GdipTranslateTextureTransform(hBrush, x, y, 0) \r\n            Call GdipScaleTextureTransform(hBrush, nScaleX, nScaleY, 0) \r\n            FillRectPlus = GdipFillRectangle(hGraphics, hBrush, x, y, Width, Height) = 0 \r\n            Call GdipDeleteBrush(hBrush)\r\n        End If \r\n        Call GdipDeleteGraphics(hGraphics) \r\n    End If\r\n \r\nEnd Function \r\n \r\nPrivate Sub InitGDI()\r\n    Dim GdipStartupInput As GDIPlusStartupInput\r\n    GdipStartupInput.GdiPlusVersion = GdiPlusVersion\r\n    Call GdiplusStartup(GdipToken, GdipStartupInput, ByVal 0)\r\nEnd Sub \r\n \r\nPrivate Sub TerminateGDI()\r\n    Call GdiplusShutdown(GdipToken)\r\nEnd Sub\r\n  \r\nPrivate Sub Form_Load()\r\n    Dim hImage As Long \r\n    Me.AutoRedraw = True \r\n    InitGDI \r\n    If GdipLoadImageFromFile(StrPtr(App.Path &amp; &quot;\\Text.png&quot;), hImage) = 0 Then \r\n        FillRectPlus Me.hdc, hImage, 10, 10, 200, 200 \r\n        Call GdipDisposeImage(hImage)\r\n    End If \r\n    TerminateGDI\r\nEnd Sub\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Esta funci\u00f3n la misma pero utilizando GDI Plus con m\u00e1s opciones, es muy \u00fatil a hora de trabajar con gr\u00e1ficos ya que se gana mucha velocidad. Option Explicit &#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8216;Autor: Leandro Ascierto &#8216;Web: www.leandroascierto.com.ar &#8216;Fecha 02\/04\/2010 &#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; Private Declare Function GdipCreateFromHDC Lib &quot;gdiplus&quot; (ByVal hdc As Long, ByRef graphics As Long) As Long Private Declare <a href='https:\/\/leandroascierto.com\/blog\/fillrectplus\/' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[61],"class_list":["post-381","post","type-post","status-publish","format-standard","hentry","category-graficos","tag-gdi-gdi-plus","category-41-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/posts\/381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/comments?post=381"}],"version-history":[{"count":2,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/posts\/381\/revisions"}],"predecessor-version":[{"id":491,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/posts\/381\/revisions\/491"}],"wp:attachment":[{"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/media?parent=381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/categories?post=381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/tags?post=381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}