I create 1 image with Gdip by merging the Clipboard content and a file.
It works well, but my problem is that
- either the file size is too big (PNG - about 4 MB)
- or the quality is really really bad (JPG)
I also tried changing the jpg quality, but the result is always the same.
As sheet anchor I could use an IrfanView batch which re-saves the png image as png.
However, I' hope it can be solved with Gdip.
The image file left (wallpaper) is a 357 KB jpg file - so it can't be the reason for the huge file size.
When I create a normal png screenshot (1920x1080) using Gdip, the file size is also about 400 KB.
For this reason I believe there's an error in my code which leads to this illogical huge file size.
Code: Select all
xl := ComObjActive("Excel.Application") ; Anbindung an die aktive Excel-Instanz
ws := xl.ActiveSheet ; Anbindung an das aktive Arbeitsblatt
na := xl.ActiveSheet.Name ; Name des aktuellen Arbeitsblattes
pfad := "C:\Users\USER\Documents\Logitech Gaming Software\Profil-Screenshots\" ; Pfad, in dem sich die Bilder befinden
ziel = %pfad%%na%.png ; Datei = pfad + Arbeitsblattname + .png
wallpaper := "C:\Users\USER\Documents\Logitech Gaming Software\Profil-Screenshots\zhintergrund.jpg" ; wallpaper (links) - 1920x1080 - jpg - 347 KB
ws.range("A1:V44").copy ; Alles in diesem Bereich kopieren (Codes)
pToken := Gdip_Startup() ; Gdip-Instanz starten
pBitmapNew := Gdip_CreateBitmap(4480, 1440) ; Neues Bild mit Abmessungen 4480x1440 erstellen
G := Gdip_GraphicsFromImage(pBitmapNew) ; Bild aus Bilddatei erstellen
Gdip_SetSmoothingMode(G, 4) ; Anti-Aliasing 4
Gdip_SetInterpolationMode(G, 7) ; Interpolierung 7
pBitmapFileLeft := Gdip_CreateBitmapFromFile(wallpaper) ; Bild links = wallpaper
pBitmapFileRight := Gdip_CreateBitmapFromClipboard() ; Bild rechts = Zwischenablage (Excel-Codes)
Gdip_DrawImage(G, pBitmapFileLeft, 0, 0, 1920, 1080, 0, 0, 1920, 1080) ; Positionierung (x, y), Ziel-Auflösung (x, y), Start (x, y), Ende (x, y)
Gdip_DrawImage(G, pBitmapFileRight, 1920, 0, 2560, 1440, 1, 1, 2560, 1440) ; Positionierung (x, y), Ziel-Auflösung (x, y), Start (x, y), Ende (x, y)
Gdip_SaveBitmapToFile(pBitmapNew, ziel) ; Neu erstelltes Bild in definiertes Verzeichnis speichern
Gdip_DisposeImage(pBitmapNew), Gdip_DisposeImage(pBitmapFileLeft), Gdip_DisposeImage(pBitmapFileRight) ; Alles aus dem Speicher entfernen
Gdip_DeleteGraphics(G) ; Rest-Grafiken löschen
Gdip_Shutdown(pToken) ; Gdip-Instanz schließen
Regards