Jump to content

GDIPlus Funcions


 Share

Recommended Posts

Hi everyone...

Can someone help me to finish my script?

I'm truing to join few small pictures to one big picture with GDIPlus functions...

Is it possible ? or maybe other ways to do this ?

I started to write script, but can't finish it :)

Eny Ideas ?

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <ScreenCapture.au3>

;Opt('MustDeclareVars', 1)

Global $search,$file,$bitnik,$hClone

$search = FileFindFirstFile("*.bmp")
If $search = -1 Then Exit

_GDIPlus_Startup ()

While 1
$file = FileFindNextFile($search)
 If @error Then ExitLoop

MsgBox(4096, "File:", $file)

$hImage = _GDIPlus_ImageLoadFromFile ($file)
$iX = _GDIPlus_ImageGetWidth ($hImage)
$iY = _GDIPlus_ImageGetHeight ($hImage)
$hClone = _GDIPlus_BitmapCloneArea ($hImage, 0, 0, $iX, $iY, $GDIP_PXF24RGB)

WEnd
FileClose($search)
_GDIPlus_ImageSaveToFile ($hClone, @ScriptDir&"\ready.bmp")
_GDIPlus_BitmapDispose($hImage)
_GDIPlus_ShutDown ()
[RU] Zone
Link to comment
Share on other sites

I'm truing to join few small pictures to one big picture with GDIPlus functions...

What is the end result supposed to look like? Are you trying to make 1 picture with all the other pictures in it in full size? What type of limitations do you want to put on the number and sizes of the pictures? Would you rather see thumbnails?

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

Here you are:

#include <File.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup()

$sPath = @ScriptDir
$aFiles = _FileListToArray($sPath, "*.bmp", 1)
Global $aImage[$aFiles[0] + 1][4]

$iWidth = 0
$iHeight = 0
$iCnt = 1
For $i = 1 To $aFiles[0]
    $aImage[$iCnt][0] = _GDIPlus_ImageLoadFromFile($sPath & "\" & $aFiles[$i])
    If @error Then ContinueLoop
    $aImage[$iCnt][1] = _GDIPlus_ImageGetWidth($aImage[$iCnt][0])
    $aImage[$iCnt][2] = _GDIPlus_ImageGetHeight($aImage[$iCnt][0])
    $iWidth += $aImage[$iCnt][1]
    If $aImage[$iCnt][2] > $iHeight Then $iHeight = $aImage[$iCnt][2]
    $aImage[$iCnt][3]=$sPath & "\" & $aFiles[$i]
    $iCnt += 1
Next
$aImage[0][0] = $iCnt - 1

$hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap)

$iX = 0
For $i = 1 To $aImage[0][0]
    ConsoleWrite($aImage[$i][3] & @CRLF)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $aImage[$i][0], $iX, 0, $aImage[$i][1], $aImage[$i][2])
    $iX += $aImage[$i][1]
    _GDIPlus_ImageDispose($aImage[$i][0])
Next

_GDIPlus_ImageSaveToFile($hBitmap, $sPath & "\_Combined.jpg")

_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()


; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_BitmapCreateFromScan0
; Description ...: Creates a Bitmap object based on an array of bytes along with size and format information
; Syntax.........: _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight[, $iStride = 0[, $iPixelFormat = 0x0026200A[, $pScan0 = 0]]])
; Parameters ....: $iWidth         - The bitmap width, in pixels
;                  $iHeight     - The bitmap height, in pixels
;                  $iStride     - Integer that specifies the byte offset between the beginning of one scan line and the next. This
;                  +is usually (but not necessarily) the number of bytes in the pixel format (for example, 2 for 16 bits per pixel)
;                  +multiplied by the width of the bitmap. The value passed to this parameter must be a multiple of four
;                  $iPixelFormat - Specifies the format of the pixel data. Can be one of the following:
;                  |$GDIP_PXF01INDEXED   - 1 bpp, indexed
;                  |$GDIP_PXF04INDEXED   - 4 bpp, indexed
;                  |$GDIP_PXF08INDEXED   - 8 bpp, indexed
;                  |$GDIP_PXF16GRAYSCALE - 16 bpp, grayscale
;                  |$GDIP_PXF16RGB555    - 16 bpp; 5 bits for each RGB
;                  |$GDIP_PXF16RGB565    - 16 bpp; 5 bits red, 6 bits green, and 5 bits blue
;                  |$GDIP_PXF16ARGB1555  - 16 bpp; 1 bit for alpha and 5 bits for each RGB component
;                  |$GDIP_PXF24RGB       - 24 bpp; 8 bits for each RGB
;                  |$GDIP_PXF32RGB       - 32 bpp; 8 bits for each RGB. No alpha.
;                  |$GDIP_PXF32ARGB      - 32 bpp; 8 bits for each RGB and alpha
;                  |$GDIP_PXF32PARGB     - 32 bpp; 8 bits for each RGB and alpha, pre-mulitiplied
;                  $pScan0        - Pointer to an array of bytes that contains the pixel data. The caller is responsible for
;                  +allocating and freeing the block of memory pointed to by this parameter.
; Return values .: Success      - Returns a handle to a new Bitmap object
;                  Failure      - 0 and either:
;                  |@error and @extended are set if DllCall failed
;                  |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources
; Related .......: _GDIPlus_ImageDispose
; Link ..........; @@MsdnLink@@ GdipCreateBitmapFromScan0
; Example .......; Yes
; ===============================================================================================================================
Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)

    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[6]
EndFunc   ;==>_GDIPlus_BitmapCreateFromScan0
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...