<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Обрезка изображения]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10258&amp;type=atom" />
	<updated>2014-12-19T17:20:32Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=10258</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Обрезка изображения]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89603#p89603" />
			<content type="html"><![CDATA[<p>Вот мощная библиотека для роботы с GUI, тут также есть средство для выпиливания изображений<br /><a href="http://www.autohotkey.com/board/topic/29449-gdi-standard-library-145-by-tic/">http://www.autohotkey.com/board/topic/2 … 45-by-tic/</a></p><p>Туториал с сайта по изображениям (нужно скачать и поместить библиотеку в папку со скриптом), но я не совсем понимаю библиотеку так что может кто другой объяснит:<br /></p><div class="codebox"><pre><code>
; gdi+ ahk tutorial 6 written by tic (Tariq Porter)
; Requires Gdip.ahk either in your Lib folder as standard library or using #Include
;
; Example to take files from disk, load them onto a background and save back to disk

#SingleInstance, Force
#NoEnv
SetBatchLines, -1

; Uncomment if Gdip.ahk is not in your standard library
#Include, Gdip_All.ahk

; Specify both of the files we are going to use
File1 = mario.png
File2 = link.png

; Start gdi+
If !pToken := Gdip_Startup()
{
    MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
    ExitApp
}

; If the images we want to work with do not exist on disk, then download them...
If !(FileExist(File1) &amp;&amp; FileExist(File2))
{
    UrlDownloadToFile, http://www.autohotkey.net/~tic/mario.png, mario.png
    UrlDownloadToFile, http://www.autohotkey.net/~tic/link.png, link.png
}


; Create a 500x500 pixel gdi+ bitmap (this will be the entire drawing area we have to play with)
pBitmap := Gdip_CreateBitmap(600, 600)

; Get a pointer to the graphics of the bitmap, for use with drawing functions
G := Gdip_GraphicsFromImage(pBitmap)

; Create a green brush (this will be used to fill the background with green). The brush is fully opaque (ARGB)
pBrush := Gdip_BrushCreateSolid(0xff00ff00)

; Filll the entire graphics of the bitmap with the green brush (this will be out background colour)
Gdip_FillRectangle(G, pBrush, 0, 0, 600, 600)

; Delete the brush created to save memory as we don&#039;t need the same brush anymore
Gdip_DeleteBrush(pBrush)


; Get bitmaps for both the files we are going to be working with
pBitmapFile1 := Gdip_CreateBitmapFromFile(File1), pBitmapFile2 := Gdip_CreateBitmapFromFile(File2)

; Get the width and height of the 1st bitmap
Width := Gdip_GetImageWidth(pBitmapFile1), Height := Gdip_GetImageHeight(pBitmapFile1)

; Draw the 1st bitmap (1st image) onto our &quot;canvas&quot; (the graphics of the original bitmap we created) with the same height and same width
; at coordinates (25,30).....We will be ignoring the matrix parameter for now. This can be used to change opacity and colours when drawing
Gdip_DrawImage(G, pBitmapFile1, 25, 30, Width, Height, 0, 0, Width, Height)


; Do the same again for the 2nd file, but change the coordinates to (250,260).....

Width := Gdip_GetImageWidth(pBitmapFile2), Height := Gdip_GetImageHeight(pBitmapFile2)
Gdip_DrawImage(G, pBitmapFile2, 250, 260, Width, Height, 0, 0, Width, Height)

; Dispose of both of these bitmaps we created from the images on disk, as they are now been used...They are on
; the graphics of the bitmap of our created &quot;canvas&quot;
Gdip_DisposeImage(pBitmapFile1), Gdip_DisposeImage(pBitmapFile2)


; Save the bitmap to file &quot;File.png&quot; (extension can be .png,.bmp,.jpg,.tiff,.gif)
; Bear in mind transparencies may be lost with some image formats and will appear black
Gdip_SaveBitmapToFile(pBitmap, &quot;FinalImage.png&quot;)

; The bitmap can be deleted
Gdip_DisposeImage(pBitmap)

; The graphics may now be deleted
Gdip_DeleteGraphics(G)

; ...and gdi+ may now be shutdown
Gdip_Shutdown(pToken)
ExitApp
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Eduard]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28482</uri>
			</author>
			<updated>2014-12-19T17:20:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89603#p89603</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Обрезка изображения]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=89599#p89599" />
			<content type="html"><![CDATA[<p>Приветствую, интерес такой вопрос, можно ли средствами АХК (или &quot;недалеко&quot; от него) обрезать изображение? Намекните в какую сторону копать. </p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p>Пример: есть изображение 100 на 400, а мне нужна первая часть 100 на 100 для последующих действий.</p></div></div>]]></content>
			<author>
				<name><![CDATA[Zmey25]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27845</uri>
			</author>
			<updated>2014-12-19T14:53:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=89599#p89599</id>
		</entry>
</feed>
