AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GDI+ standard library 1.45 by tic
Goto page Previous  1, 2, 3 ... 16, 17, 18 ... 60, 61, 62  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
mrr19121970



Joined: 30 Apr 2009
Posts: 29

PostPosted: Thu Aug 27, 2009 11:46 am    Post subject: Reply with quote

@StevenSanders

You're going to have to try it yourself.



@leef_me

Concerning Keystoning:

see here

http://msdn.microsoft.com/en-us/library/ms533834%28VS.85%29.aspx

Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)

Concerning fading in and out:

see my post "Wed Aug 19, 2009 12:53 pm"
Back to top
View user's profile Send private message
StevenSanders
Guest





PostPosted: Thu Aug 27, 2009 5:23 pm    Post subject: Reply with quote

Shouldn't this produce a 03D12F (r=3, g=209, b=47) output? ... or where am I working this wrong? I am very puzzled by this. Hopefully you can shine some light on this Very Happy

Code:


myColMat = ("0|0|0|-1|1|3|209|47|0|0|3|209|47|0|0|3|209|47|0|0|3|209|47|0|0")

Back to top
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Thu Aug 27, 2009 6:30 pm    Post subject: Reply with quote

mrr19121970 wrote:
@leef_me

Concerning fading in and out:

see my post "Wed Aug 19, 2009 12:53 pm"

Thank you for your response, concerning fading. I have it working Exclamation Smile BTW, I found your post by date, we are in different timezones Wink
I have two suggestions for your original post:

>>Change (blank) line 33 to (initially 50%):

Code:
Gui, 1: Add, Slider, x10 y+20 w300 Tooltip vTransparency Range1-100, 50


>>Change line 124 (correct typo):

Code:
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight, Transparency/100)


I'll still have to look at the Keystone link you gave.
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1786

PostPosted: Fri Aug 28, 2009 3:44 pm    Post subject: Reply with quote

Something to note when making things fade is that you should never have a continual sleep when looping:

Never do:

Code:
Transparency := 255
Loop, % Transparency/5
{
   Gdip_GraphicsClear(G)
   Gdip_DrawImage(G, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight, Transparency)
   Transparency -= 5
   Sleep, 10
}


but instead you should do something like the following. It will fade out

Code:
TotalTime := 250
StartTime := A_TickCount
Loop
{
   Transparency := ((TimeElapsed := A_TickCount-StartTime) < TotalTime) ? 255*(1-(TimeElapsed/TotalTime)) : 0
   If (Transparency = 0)
   Break
   Gdip_GraphicsClear(G)
   Gdip_DrawImage(G, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight, Transparency)
}


This is a much better method as it does not depend on the speed of the computer, but instead will always take the specified length of time to fade in/out. Just thought Id note it in case anyone does it the other way. It might need to be altered. I just typed it without testing...
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Fri Aug 28, 2009 5:23 pm    Post subject: Reply with quote

Hi tic,
Thanks for your suggestion. I haven't taken the time to try your code, but I think I understand your caution.

It's not that the 'sleep' would hurt the code, it's that it would annoy the person viewing the image. Instead of a smooth transition, they'd see:
dim, pause, dim, pause . ... of course 10 ms doesn't seem like a long delay.

BTW, I briefly looked at the suggestion mrr19121970 made for keystone
I'm not sure (maybe I should be quiet and find out Embarassed ) if it will handle this shape http://en.wikipedia.org/wiki/Trapezoid

Thanks again for the library and functions.
Back to top
View user's profile Send private message
StevenSanders
Guest





PostPosted: Fri Aug 28, 2009 6:33 pm    Post subject: Reply with quote

Actually, this is all I really need for a color 0-100 or - conversion in this matrix. It works great once you fine tune it such as with the example you posted, to apply the matrix need. Very Happy
Back to top
mrr19121970



Joined: 30 Apr 2009
Posts: 29

PostPosted: Mon Aug 31, 2009 1:12 pm    Post subject: Reply with quote

to expand on TIC's post to make it into a working example...

Starting with Gdip.Tutorial.10-Rotate.Flip.or.Mirror.an.image.ahk

Comment out lines 124 & 130. After line 130 add the following code:

Code:

TotalTime := 5000
StartTime := A_TickCount
Loop
{
   Transparency := ((TimeElapsed := A_TickCount-StartTime) < TotalTime) ? 100*(1-(TimeElapsed/TotalTime)) : 0
   If (Transparency = 0)
      Break
   Gdip_GraphicsClear(G)
   Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight, Transparency/100)
   UpdateLayeredWindow(hwnd2, hdc, (A_ScreenWidth-RWidth)//2, (A_ScreenHeight-RHeight)//2, RWidth, RHeight)
}
Back to top
View user's profile Send private message
Staci
Guest





PostPosted: Mon Sep 07, 2009 12:50 am    Post subject: Reply with quote

Hi, I have seen some great basic examples how to draw with these libraries. They are great! I have had fun trying to draw things, ... and I am hoping to see an example of how to draw a wavie line?

This is kind of what I want, just a line that is wavie? Smile

Back to top
mrr19121970



Joined: 30 Apr 2009
Posts: 29

PostPosted: Tue Sep 08, 2009 12:25 pm    Post subject: Reply with quote

using Gdip.Tutorial.1-Draw.Shapes.ahk as a starting point. Replace the code:

Code:

; Create a fully opaque red brush (ARGB = Transparency, red, green, blue) to draw a circle
pBrush := Gdip_BrushCreateSolid(0xffff0000)

; Fill the graphics of the bitmap with an ellipse using the brush created
; Filling from coordinates (100,50) an ellipse of 200x300
Gdip_FillEllipse(G, pBrush, 100, 50, 200, 300)

; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)

; Create a slightly transparent (66) blue brush (ARGB = Transparency, red, green, blue) to draw a rectangle
pBrush := Gdip_BrushCreateSolid(0x660000ff)

; Fill the graphics of the bitmap with a rectangle using the brush created
; Filling from coordinates (250,80) a rectangle of 300x200
Gdip_FillRectangle(G, pBrush, 250, 80, 300, 200)

; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)


With

Code:

; Create a fully opaque red pen (ARGB = Transparency, red, green, blue)
pPen1 := Gdip_CreatePen(0xffff0000,3)

; Create a fully opaque green pen (ARGB = Transparency, red, green, blue)
pPen2 := Gdip_CreatePen(0xff00ff00,3)

; The length of the wavy line
WavyLen := 200

; The number of the waves (smaller=more, larger=less)
WavyX := 20

; The depth of the waves (smaller=flatter, larger=curved)
WavyY := 10

; The starting position
StartX := 10
StartY := 10
PrevX := StartX
PrevY := StartY

; Paint the Sine Wave
WavyIdx=0
Loop,%WavyLen%
{
   NewX := StartX + WavyIdx
   NewY := StartY + (Sin(WavyIdx/WavyX)*WavyY)
   Gdip_DrawLine(G, pPen1, PrevX, PrevY, NewX, NewY)
   PrevX := NewX
   PrevY := NewY
   WavyIdx++
}
Gdip_DrawLine(G, pPen2, StartX, StartY+(WavyY*2), StartX+WavyLen, StartY+(WavyY*2))

; Delete the pens as they are no longer needed and wastes memory
Gdip_DeletePen(pPen1)
Gdip_DeletePen(pPen2)
Back to top
View user's profile Send private message
Staci
Guest





PostPosted: Wed Sep 09, 2009 4:28 pm    Post subject: Reply with quote

This is neat & cool how easy the function is to configure! ~~ But - I noticed the sine-wave itself, with any Pen size over 1, had some impurities in it. The larger it is drawn, the more evident it is. Can that be fixed? I tried to run it twice, but overdrawing it does not help. Very Happy Very Happy Staci
Back to top
mrr19121970



Joined: 30 Apr 2009
Posts: 29

PostPosted: Wed Sep 09, 2009 6:01 pm    Post subject: Reply with quote

There is always more than one way to skin a rabbit Very Happy

Code:
; Pen Thickness
PenThickness := 50

; Create a fully opaque red pen (ARGB = Transparency, red, green, blue)
pPen1 := Gdip_CreatePen(0xffff0000,PenThickness)

; Create a fully opaque green pen (ARGB = Transparency, red, green, blue)
pPen2 := Gdip_CreatePen(0xff00ff00,1)

; The length of the wavy line
WavyLen := 1000

; The number of the waves (smaller=more, larger=less)
WavyX := 50

; The depth of the waves (smaller=flatter, larger=curved)
WavyY := 20

; The starting position
StartX := 10
StartY := 10
PrevX := StartX
PrevY := StartY

; Paint the Sine Wave
WavyIdx=0
Loop,%WavyLen%
{
   NewX := StartX + WavyIdx
   NewY := StartY + (Sin(WavyIdx/WavyX)*WavyY)
   Gdip_DrawLine(G, pPen1, PrevX, PrevY, NewX, NewY)
   PrevX := NewX
   PrevY := NewY
   WavyIdx++
}

; The starting position
StartX := 10
StartY := StartY + PenThickness

; Paint the Sine Wave
WavyIdx=0
Loop,%WavyLen%
{
   NewX := StartX + WavyIdx
   NewY := StartY + (Sin(WavyIdx/WavyX)*WavyY)
   Gdip_DrawLine(G, pPen2, NewX, NewY, NewX, NewY+PenThickness)
   WavyIdx++
}

; Delete the pens as they are no longer needed and wastes memory
Gdip_DeletePen(pPen1)
Gdip_DeletePen(pPen2)


Last edited by mrr19121970 on Wed Sep 09, 2009 8:56 pm; edited 1 time in total
Back to top
View user's profile Send private message
Staci
Guest





PostPosted: Wed Sep 09, 2009 6:44 pm    Post subject: Reply with quote

YOU ARE AWESOME
Back to top
mrr19121970



Joined: 30 Apr 2009
Posts: 29

PostPosted: Wed Sep 09, 2009 9:03 pm    Post subject: Reply with quote

Similarly for vertical waves:
Code:

; Paint the Sine Wave
WavyIdx=0
Loop,%WavyLen%
{
   NewX := StartX + (Sin(WavyIdx/WavyX)*WavyY)
   NewY := StartY + WavyIdx
   Gdip_DrawLine(G, pPen2, NewX, NewY, NewX+PenThickness, NewY)
   WavyIdx++
}


I think you'd be best rotating if you wanted something slightly at an angle.
Back to top
View user's profile Send private message
jlrjlr



Joined: 23 Jul 2009
Posts: 4

PostPosted: Fri Sep 11, 2009 11:13 am    Post subject: Question : How to erase Reply with quote

Is it possible to 'erase' some part of what has been painted on the "LayeredWindow" ?

Based on Tutorial 2 it is possible to paint on LayeredWindow. Now I would like to have an 'eraser' to erase parts of what has been painted.

I try by painting over some "white", with more or less transparency, but, as expected, it paints white over the 'shapes'. This is not erasing and recovering the screen below the shapes.

If any one has some hints, many thanks.

Thanks to Tic's library and tutorial GDI usage is made easy and fun.
Back to top
View user's profile Send private message
mrr19121970



Joined: 30 Apr 2009
Posts: 29

PostPosted: Fri Sep 11, 2009 12:31 pm    Post subject: Reply with quote

Lexikos wrote:
mrr19121970, I think there are (at least) two ways to erase:
  • Gdip_GraphicsClear. To erase only part, set clipping with Gdip_SetClipRect.
  • Set overwrite mode with Gdip_SetCompositingMode, create a transparent brush with Gdip_BrushCreateSolid (passing an ARGB value with zero for the alpha component), then call Gdip_FillRectangle.


This was asked & answered 2 pages back.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 16, 17, 18 ... 60, 61, 62  Next
Page 17 of 62

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group