rootx

[SOLVED] preserve ascpect ratio _GDIPlus

12 posts in this topic

#1 ·  Posted (edited)

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

Example()

Func Example()
    Local $hImage, $sFile, $hGUI, $hGraphic, $hThumbnail, $iW_new, $iH_new

    $sFile = FileOpenDialog("Please select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST))
    If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30)

    _GDIPlus_Startup()

    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Or Not $hImage Then
        MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!")
    Else
        $hGUI = GUICreate("GDI+ _GDIPlus_ImageGetThumbnail Demo", 320, 200)
        GUISetBkColor(0x202020)
        GUISetState()

        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
        $hThumbnail = _GDIPlus_ImageGetThumbnail($hImage, 96, 96)
        $iW_new = _GDIPlus_ImageGetWidth($hThumbnail)
        $iH_new = _GDIPlus_ImageGetHeight($hThumbnail)
        _GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumbnail, (320 - $iW_new) / 2, (200 - $iH_new) / 2, $iW_new, $iH_new) ;center image in GUI

        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_ImageDispose($hThumbnail)
    EndIf

    _GDIPlus_Shutdown()
EndFunc   ;==>Example

The image is resized but also rotated, why? I just want to reduce its size without changing the appearance.

Someone can give me some information.

THX

Edited by rootx

Share this post


Link to post
Share on other sites



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

Example()

Func Example()
    Local $hImage, $sFile, $hGUI, $hGraphic, $hThumbnail, $iW_new, $iH_new

    $sFile = FileOpenDialog("Please select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST))
    If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30)

    _GDIPlus_Startup()

    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Or Not $hImage Then
        MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!")
    Else
        $hGUI = GUICreate("GDI+ _GDIPlus_ImageGetThumbnail Demo", 320, 200)
        GUISetBkColor(0x202020)
        GUISetState()

        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
        $hThumbnail = _GDIPlus_ImageGetThumbnail($hImage, 96, 96)
        $iW_new = _GDIPlus_ImageGetWidth($hThumbnail)
        $iH_new = _GDIPlus_ImageGetHeight($hThumbnail)
        If $iH_new < $iW_new Then
            _GDIPlus_ImageRotateFlip($hThumbnail,1)
            MsgBox("","",$iH_new&" "&$iW_new)
        EndIf
         _GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumbnail, (320 - $iW_new) / 2, (200 - $iH_new) / 2, $iW_new, $iH_new) ;center image in

        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_ImageDispose($hThumbnail)
    EndIf

    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Now... the image is oriented correctly but the aspect ratio is wrong!

Share this post


Link to post
Share on other sites
#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $sFile, $hGUI, $hGraphic, $hThumbnail, $iW_new, $iH_new

    $sFile = FileOpenDialog("Please select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST))
    If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30)

    _GDIPlus_Startup()

    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Or Not $hImage Then
        MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!")
    Else
        $hGUI = GUICreate("GDI+ _GDIPlus_ImageGetThumbnail Demo", 320, 200)
        GUISetBkColor(0x202020)
        GUISetState()

        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
        $hThumbnail = _GDIPlus_ImageGetThumbnail($hImage, 96, 96)
        $iW_new = _GDIPlus_ImageGetWidth($hThumbnail)
        $iH_new = _GDIPlus_ImageGetHeight($hThumbnail)
        _GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumbnail, (320 - $iW_new) / 2, (200 - $iH_new) / 2, $iW_new, $iH_new) ;center image in GUI

        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_ImageDispose($hThumbnail)
    EndIf

    _GDIPlus_Shutdown()
EndFunc   ;==>Example

The image is resized but also rotated, why? I just want to reduce its size without changing the appearance.

Someone can give me some information.

THX

For me the image is ok - no flipping. What OS are you using?


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Windows 8 64bit, image iphone dimension 2448x3624.

Mistake with IOS image!!! I give you one photo.

THX

3.jpg

Edited by rootx

Share this post


Link to post
Share on other sites

I'm also using Win8 x64. I've tested it with the largest image I found on my disk (7360x4912) and it worked properly.


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Please explain me.

THX

Image info details

Image: 3.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 3264x2448+0+0
  Resolution: 72x72
  Print size: 45.3333x34
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 131.231 (0.51463)
      standard deviation: 55.6092 (0.218075)
      kurtosis: -0.30064
      skewness: -0.883831
    Green:
      min: 1 (0.00392157)
      max: 255 (1)
      mean: 119.85 (0.469998)
      standard deviation: 52.6656 (0.206532)
      kurtosis: -0.502702
      skewness: -0.64582
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 106.636 (0.418181)
      standard deviation: 49.7939 (0.19527)
      kurtosis: -0.552564
      skewness: -0.398015
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 119.239 (0.467603)
      standard deviation: 52.7431 (0.206835)
      kurtosis: -0.410764
      skewness: -0.620568
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 3264x2448+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 93
  Orientation: RightTop
  Properties:
    date:create: 2015-12-22T15:42:53+01:00
    date:modify: 2015-12-06T01:23:00+01:00
    exif:ApertureValue: 7983/3509
    exif:BrightnessValue: -449/297
    exif:ColorSpace: 1
    exif:ComponentsConfiguration: 1, 2, 3, 0
    exif:Compression: 6
    exif:DateTime: 2015:03:16 17:19:53
    exif:DateTimeDigitized: 2015:03:16 17:19:53
    exif:DateTimeOriginal: 2015:03:16 17:19:53
    exif:ExifImageLength: 2448
    exif:ExifImageWidth: 3264
    exif:ExifOffset: 204
    exif:ExifVersion: 48, 50, 50, 49
    exif:ExposureBiasValue: 0/1
    exif:ExposureMode: 0
    exif:ExposureProgram: 2
    exif:ExposureTime: 1/15
    exif:Flash: 16
    exif:FlashPixVersion: 48, 49, 48, 48
    exif:FNumber: 11/5
    exif:FocalLength: 83/20
    exif:FocalLengthIn35mmFilm: 29
    exif:GPSAltitude: 41083/96
    exif:GPSAltitudeRef: 0
    exif:GPSDateStamp: 2015:03:16
    exif:GPSDestBearing: 147620/779
    exif:GPSDestBearingRef: T
    exif:GPSImgDirection: 7419/781
    exif:GPSImgDirectionRef: T
    exif:GPSInfo: 1598
    exif:GPSLatitude: 47/1, 24/1, 2669/100
    exif:GPSLatitudeRef: N
    exif:GPSLongitude: 8/1, 34/1, 3851/100
    exif:GPSLongitudeRef: E
    exif:GPSSpeed: 11/25
    exif:GPSSpeedRef: K
    exif:GPSTimeStamp: 16/1, 19/1, 5324/100
    exif:ISOSpeedRatings: 640
    exif:JPEGInterchangeFormat: 1982
    exif:JPEGInterchangeFormatLength: 7625
    exif:Make: Apple
    exif:MakerNote: 65, 112, 112, 108, 101, 32, 105, 79, 83, 0, 0, 1, 77, 77, 0, 10, 0, 1, 0, 9, 0, 0, 0, 1, 0, 0, 0, 2, 0, 2, 0, 7, 0, 0, 2, 46, 0, 0, 0, 140, 0, 3, 0, 7, 0, 0, 0, 104, 0, 0, 2, 186, 0, 4, 0, 9, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0, 9, 0, 0, 0, 1, 0, 0, 0, 144, 0, 6, 0, 9, 0, 0, 0, 1, 0, 0, 0, 136, 0, 7, 0, 9, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0, 10, 0, 0, 0, 3, 0, 0, 3, 34, 0, 9, 0, 9, 0, 0, 0, 1, 0, 0, 1, 19, 0, 14, 0, 9, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 98, 112, 108, 105, 115, 116, 48, 48, 79, 17, 2, 0, 216, 0, 23, 1, 14, 1, 243, 0, 212, 0, 63, 1, 57, 1, 35, 1, 14, 1, 4, 1, 249, 0, 242, 0, 233, 0, 229, 0, 223, 0, 217, 0, 255, 0, 31, 1, 15, 1, 4, 1, 244, 0, 166, 0, 241, 0, 8, 1, 248, 0, 243, 0, 235, 0, 231, 0, 227, 0, 222, 0, 216, 0, 213, 0, 23, 1, 29, 1, 17, 1, 7, 1, 252, 0, 236, 0, 91, 0, 192, 0, 223, 0, 221, 0, 220, 0, 219, 0, 219, 0, 217, 0, 211, 0, 210, 0, 43, 1, 28, 1, 16, 1, 7, 1, 250, 0, 219, 0, 19, 0, 33, 0, 156, 0, 195, 0, 201, 0, 205, 0, 209, 0, 210, 0, 209, 0, 206, 0, 44, 1, 26, 1, 13, 1, 2, 1, 250, 0, 139, 0, 13, 0, 12, 0, 18, 0, 115, 0, 178, 0, 191, 0, 199, 0, 200, 0, 202, 0, 201, 0, 35, 1, 20, 1, 7, 1, 0, 1, 245, 0, 54, 0, 12, 0, 12, 0, 16, 0, 15, 0, 75, 0, 164, 0, 186, 0, 193, 0, 195, 0, 196, 0, 23, 1, 7, 1, 1, 1, 247, 0, 191, 0, 13, 0, 30, 0, 73, 0, 57, 0, 29, 0, 16, 0, 86, 0, 127, 0, 181, 0, 188, 0, 189, 0, 8, 1, 246, 0, 240, 0, 232, 0, 100, 0, 84, 0, 97, 0, 119, 0, 74, 0, 50, 0, 43, 0, 151, 0, 124, 0, 109, 0, 169, 0, 181, 0, 239, 0, 221, 0, 213, 0, 205, 0, 26, 0, 97, 0, 116, 0, 121, 0, 71, 0, 80, 0, 109, 0, 153, 0, 148, 0, 135, 0, 101, 0, 155, 0, 209, 0, 188, 0, 187, 0, 129, 0, 13, 0, 67, 0, 128, 0, 113, 0, 68, 0, 83, 0, 158, 0, 154, 0, 148, 0, 143, 0, 135, 0, 103, 0, 168, 0, 161, 0, 163, 0, 54, 0, 12, 0, 50, 0, 112, 0, 99, 0, 86, 0, 110, 0, 158, 0, 153, 0, 148, 0, 144, 0, 137, 0, 131, 0, 138, 0, 140, 0, 128, 0, 14, 0, 11, 0, 34, 0, 109, 0, 103, 0, 82, 0, 154, 0, 156, 0, 154, 0, 149, 0, 143, 0, 136, 0, 130, 0, 118, 0, 126, 0, 74, 0, 15, 0, 13, 0, 24, 0, 79, 0, 115, 0, 110, 0, 155, 0, 155, 0, 152, 0, 148, 0, 141, 0, 137, 0, 131, 0, 100, 0, 112, 0, 33, 0, 20, 0, 18, 0, 26, 0, 38, 0, 85, 0, 142, 0, 151, 0, 152, 0, 148, 0, 145, 0, 141, 0, 136, 0, 131, 0, 87, 0, 81, 0, 27, 0, 31, 0, 28, 0, 23, 0, 39, 0, 82, 0, 139, 0, 144, 0, 145, 0, 145, 0, 141, 0, 138, 0, 135, 0, 132, 0, 145, 0, 54, 0, 49, 0, 49, 0, 40, 0, 28, 0, 32, 0, 114, 0, 130, 0, 136, 0, 140, 0, 140, 0, 140, 0, 138, 0, 134, 0, 132, 0, 0, 8, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 12, 98, 112, 108, 105, 115, 116, 48, 48, 212, 1, 2, 3, 4, 5, 6, 7, 8, 85, 102, 108, 97, 103, 115, 85, 118, 97, 108, 117, 101, 85, 101, 112, 111, 99, 104, 89, 116, 105, 109, 101, 115, 99, 97, 108, 101, 16, 1, 19, 0, 0, 231, 207, 252, 210, 170, 251, 16, 0, 18, 59, 154, 202, 0, 8, 17, 23, 29, 35, 45, 47, 56, 58, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 0, 133, 0, 0, 9, 45, 255, 255, 253, 149, 0, 0, 6, 111, 255, 255, 243, 115, 0, 0, 13, 114
    exif:MeteringMode: 5
    exif:Model: iPhone 5s
    exif:Orientation: 6
    exif:ResolutionUnit: 2
    exif:SceneCaptureType: 0
    exif:SceneType: 1
    exif:SensingMethod: 2
    exif:ShutterSpeedValue: 5173/1324
    exif:Software: 8.1.3
    exif:SubjectArea: 1631, 1223, 1795, 1077
    exif:SubSecTimeDigitized: 684
    exif:SubSecTimeOriginal: 684
    exif:WhiteBalance: 0
    exif:XResolution: 72/1
    exif:YCbCrPositioning: 1
    exif:YResolution: 72/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: 5d074f1c59e8bf6025f4375242ba642a42ff5821102bc144c741d946afa83960
    unknown: 83/20, 83/20, 11/5, 11/5
  Profiles:
    Profile-exif: 12284 bytes
  Artifacts:
    filename: 3.jpg
    verbose: true
  Tainted: False
  Filesize: 1.281MB
  Number pixels: 7.99M
  Pixels per second: 94MB
  User time: 0.094u
  Elapsed time: 0:01.085
  Version: ImageMagick 6.8.9-5 Q16 x64 2014-06-26 http://www.imagemagick.org

 

3.jpg

Cattura.PNG

Edited by rootx

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

And now....

use exiftool command to remove exif info....   

exiftool -all= imagename.jpg

et voilà....

Cattura.PNG

Now work...

22.thumb.PNG.4967802cfd5288d14fdbd2fd34f

3.jpg

Cattura.PNG

Edited by rootx

Share this post


Link to post
Share on other sites

I assume your display program reads the EXIF data and rotates the image automatically.


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

No, GDIPlus will not do it automatically. I mean the screenshot in post#5 which was displayed not using Autoit and GDIPlus.

E.g. IrfanView rotates also the image by default.


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

How can I prevent _GDIPlus read orientation in Exif? As the operating system... Windows

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

You have to read out the meta data if exists and flip the image accordingly.

Try this:

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

Example()

Func Example()
    Local $hImage, $sFile, $hGUI, $hGraphic, $hThumbnail, $iW_new, $iH_new

    $sFile = FileOpenDialog("Please select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST))
    If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30)

    _GDIPlus_Startup()

    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Or Not $hImage Then
        MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!")
    Else
        Local Const $PropertyTagOrientation = 0x0112
        Local $tPropItem = _GDIPlus_ImageGetPropertyItem($hImage, $PropertyTagOrientation)
        If Not @error Then
            Local Enum $PropertyTagTypeByte = 1, $PropertyTagTypeASCII, $PropertyTagTypeShort, $PropertyTagTypeLong, $PropertyTagTypeRational, _
                        $PropertyTagTypeUndefined = 7, $PropertyTagTypeSLONG = 9, $PropertyTagTypeSRational
            Local $tagType, $tFlip
            Switch $tPropItem.Type
                Case $PropertyTagTypeLong
                    $tagType = "ulong"
                Case $PropertyTagTypeShort
                    $tagType = "ushort"
                Case $PropertyTagTypeSLONG
                    $tagType = "long"
                Case $PropertyTagTypeByte
                    $tagType = "byte"
            EndSwitch

            $tFlip = DllStructCreate($tagType & " value", $tPropItem.Value)
            Switch $tFlip.value
                Case 2
                    _GDIPlus_ImageRotateFlip($hImage, 4)
                Case 3
                    _GDIPlus_ImageRotateFlip($hImage, 2)
                Case 4
                    _GDIPlus_ImageRotateFlip($hImage, 6)
                Case 5
                    _GDIPlus_ImageRotateFlip($hImage, 5)
                Case 6
                    _GDIPlus_ImageRotateFlip($hImage, 1)
                Case 7
                    _GDIPlus_ImageRotateFlip($hImage, 7)
                Case 8
                    _GDIPlus_ImageRotateFlip($hImage, 3)
            EndSwitch
        EndIf

        $hGUI = GUICreate("GDI+ _GDIPlus_ImageGetThumbnail Demo", 320, 200)
        GUISetBkColor(0x202020)
        GUISetState()

        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
        $hThumbnail = _GDIPlus_ImageGetThumbnail($hImage, 96, 96)
        $iW_new = _GDIPlus_ImageGetWidth($hThumbnail)
        $iH_new = _GDIPlus_ImageGetHeight($hThumbnail)
        _GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumbnail, (320 - $iW_new) / 2, (200 - $iH_new) / 2, $iW_new, $iH_new) ;center image in GUI

        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_ImageDispose($hThumbnail)
    EndIf

    _GDIPlus_Shutdown()
EndFunc   ;==>Example


; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_ImageGetPropertyItem
; Description ...: Gets a specified property item (piece of metadata) from this Image object.
; Syntax ........: _GDIPlus_ImageGetPropertyItem($hImage, $iPropID)
; Parameters ....: $hImage              - A handle to an image object.
;                  $iPropID             - An integer that identifies the property item to be retrieved.
; Return values .: $tagGDIPPROPERTYITEM structure or 0 on errors
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......: _GDIPlus_ImageLoadFromFile _GDIPlus_ImageLoadFromStream
; Link ..........: Property Item Descriptions -> http://msdn.microsoft.com/en-us/library/windows/desktop/ms534416(v=vs.85).aspx
; ===============================================================================================================================
Func _GDIPlus_ImageGetPropertyItem($hImage, $iPropID)
    Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyItemSize", "handle", $hImage, "uint", $iPropID, "ulong*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] Then Return SetError(10, $aResult[0], 0)
    Local Static $tBuffer ;why static? because otherwise it would crash when running it as x64 exe (workaround)
    $tBuffer = DllStructCreate("byte[" & $aResult[3] & "]")
    $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyItem", "handle", $hImage, "uint", $iPropID, "ulong", $aResult[3], "struct*", $tBuffer)
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] Then Return SetError(11, $aResult[0], 0)
    Local Const $tagGDIPPROPERTYITEM = "uint id;ulong length;word type;ptr value"
    Local $tPropertyItem = DllStructCreate($tagGDIPPROPERTYITEM, DllStructGetPtr($tBuffer))
    If @error Then Return SetError(20, $aResult[0], 0)
    Return $tPropertyItem
EndFunc   ;==>_GDIPlus_ImageGetPropertyItem

 

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
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

  • Similar Content

    • jvds
      By jvds
      in the help is something similar to what i want to do but instead of screen capture i want to cut a rectangular chunk out of an image, _GDIPlus_GraphicsDrawImage() let me dwaw the image where i want on the x y coordinates but i want to copy a certain Width and Height from a custom X and Y coordinate.
      i went to look at ScreenCapture.au3 seems that _WinAPI_BitBlt does the job but i don't understand it, is there a simple way staying with _GDIPlus_Graphics? or any tips on how to do it with _WinAPI_BitBlt ?
      help file example
      #include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> Example() Func Example() Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic ; Initialize GDI+ library _GDIPlus_Startup() ; Capture full screen $hBitmap1 = _ScreenCapture_Capture("") $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1) ; Capture screen region $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300) $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2) ; Draw one image in another $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, 100, 100) ; Draw a frame around the inserted image _GDIPlus_GraphicsDrawRect($hGraphic, 100, 100, 400, 300) ; Save resultant image _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg") ; Clean up resources _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _WinAPI_DeleteObject($hBitmap1) _WinAPI_DeleteObject($hBitmap2) ; Shut down GDI+ library _GDIPlus_Shutdown() ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg") EndFunc ;==>Example  
    • JonBMN
      By JonBMN
      I'm trying to put an icon in the top of the GUI window using _GDIPlus.au3. I've tried using the Sleep(20) that has been suggested to no avail. Thank you for any and all help.
      Func GUI() Local $hImageGreen, $hImageRed, $hGraphic, $CheckRunning, $Parent, $ButtonInstall, $buttonUninstall, $ButtonStart, $ButtonStop, $ButtonConfigure _GDIPlus_Startup() $hImageRed = _GDIPlus_ImageLoadFromFile(@UserProfileDir & "\Desktop\SRRS\console\Red.png") $hImageGreen = _GDIPlus_ImageLoadFromFile(@UserProfileDir & "\Desktop\SRRS\console\Green.png") $Parent = GUICreate("Console", 345, 225) ConsoleWrite($hImageRed & "<-red green->" & $hImageGreen) $CheckRunning = ProcessExists("test.exe") If $CheckRunning <> 0 Then GUICtrlCreateLabel("its running!", 110, 40) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Parent) Sleep(20) _GDIPlus_GraphicsDrawImage($hGraphic, $hImageGreen, 110, 40) Else GUICtrlCreateLabel("not running!", 108, 40) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Parent) Sleep(20) _GDIPlus_GraphicsDrawImage($hGraphic, $hImageRed, 110, 40) EndIf $ButtonInstall = GUICtrlCreateButton("Install", 55, 85, 70) $ButtonUninstall = GUICtrlCreateButton("Uninstall", 55, 125, 70) $ButtonStart = GUICtrlCreateButton("Start", 210, 85) $ButtonStop = GUICtrlCreateButton("Stop", 210, 125) $ButtonConfigure = GUICtrlCreateButton("Configure", 131, 165, 70) GUICtrlCreateLabel("Is it Running?", 110, 10) GUISetState(@SW_SHOW) ;shows the GUI window