Nice bar charts example Tic! By the way, here are few functions I made;
- Gdip_ResizeBitmap()
- Gdip_RotateBitmap()
- Gdip_CropBitmap()
- Gdip_CloneBitmap()
Examples are included in comments. If you think they are useful and good enough, feel free to make them part of your Gdip library. Pastebin.
Gdip_ResizeBitmap(pBitmap, PercentOrWH, Dispose=1) { ; returns resized bitmap. By Learning one. Gdip_GetImageDimensions(pBitmap, origW, origH) if PercentOrWH contains w,h { RegExMatch(PercentOrWH, "i)w(\d*)", w), RegExMatch(PercentOrWH, "i)h(\d*)", h) NewWidth := w1, NewHeight := h1 NewWidth := (NewWidth = "") ? origW/(origH/NewHeight) : NewWidth NewHeight := (NewHeight = "") ? origH/(origW/NewWidth) : NewHeight } else NewWidth := origW*PercentOrWH/100, NewHeight := origH*PercentOrWH/100 pBitmap2 := Gdip_CreateBitmap(NewWidth, NewHeight) G2 := Gdip_GraphicsFromImage(pBitmap2), Gdip_SetSmoothingMode(G2, 4), Gdip_SetInterpolationMode(G2, 7) Gdip_DrawImage(G2, pBitmap, 0, 0, NewWidth, NewHeight) Gdip_DeleteGraphics(G2) if Dispose Gdip_DisposeImage(pBitmap) return pBitmap2 } /* ;Examples: pResizedBitmap := Gdip_ResizeBitmap(pBitmap, 120) ; resizes to 120%. Disposes of pBitmap. pResizedBitmap := Gdip_ResizeBitmap(pBitmap, 50, 0) ; resizes to 50%. Does not dispose of pBitmap. pResizedBitmap := Gdip_ResizeBitmap(pBitmap, "w180 h80") ; resizes to width: 180 height: 80 (does not maintain aspect ratio). Disposes of pBitmap. pResizedBitmap := Gdip_ResizeBitmap(pBitmap, "w200") ; resizes to width: 200, automatically adjusts height (maintains aspect ratio). Disposes of pBitmap. pResizedBitmap := Gdip_ResizeBitmap(pBitmap, "h50") ; resizes to height: 50, automatically adjusts width (maintains aspect ratio). Disposes of pBitmap. */ Gdip_RotateBitmap(pBitmap, Angle, Dispose=1) { ; returns rotated bitmap. By Learning one. Gdip_GetImageDimensions(pBitmap, Width, Height) Gdip_GetRotatedDimensions(Width, Height, Angle, RWidth, RHeight) Gdip_GetRotatedTranslation(Width, Height, Angle, xTranslation, yTranslation) pBitmap2 := Gdip_CreateBitmap(RWidth, RHeight) G2 := Gdip_GraphicsFromImage(pBitmap2), Gdip_SetSmoothingMode(G2, 4), Gdip_SetInterpolationMode(G2, 7) Gdip_TranslateWorldTransform(G2, xTranslation, yTranslation) Gdip_RotateWorldTransform(G2, Angle) Gdip_DrawImage(G2, pBitmap, 0, 0, Width, Height) Gdip_ResetWorldTransform(G2) Gdip_DeleteGraphics(G2) if Dispose Gdip_DisposeImage(pBitmap) return pBitmap2 } /* ;Examples: pRotatedBitmap := Gdip_RotateBitmap(pBitmap, 45) ; rotates bitmap for 45 degrees. Disposes of pBitmap. pRotatedBitmap := Gdip_RotateBitmap(pBitmap, 77) ; rotates bitmap for 77 degrees. Disposes of pBitmap. pRotatedBitmap := Gdip_RotateBitmap(pBitmap, -22, 0) ; rotates bitmap for -22 degrees. Does not dispose of pBitmap. */ Gdip_CropBitmap(pBitmap, left, right, up, down, Dispose=1) { ; returns cropped bitmap. Specify how many pixels you want to crop (omit) from each side of bitmap rectangle. By Learning one. Gdip_GetImageDimensions(pBitmap, origW, origH) NewWidth := origW-left-right, NewHeight := origH-up-down pBitmap2 := Gdip_CreateBitmap(NewWidth, NewHeight) G2 := Gdip_GraphicsFromImage(pBitmap2), Gdip_SetSmoothingMode(G2, 4), Gdip_SetInterpolationMode(G2, 7) Gdip_DrawImage(G2, pBitmap, 0, 0, NewWidth, NewHeight, left, up, NewWidth, NewHeight) Gdip_DeleteGraphics(G2) if Dispose Gdip_DisposeImage(pBitmap) return pBitmap2 } /* ;Examples: pCroppedBitmap := Gdip_CropBitmap(pBitmap, 10, 10, 10, 10) ; crops 10 pixels from each side of bitmap rectangle. Disposes of pBitmap. pCroppedBitmap := Gdip_CropBitmap(pBitmap, 50, 50, 0, 0) ; crops 50 pixels from left and right side of bitmap rectangle. Disposes of pBitmap. pCroppedBitmap := Gdip_CropBitmap(pBitmap, 0, 0, 77, 77, 0) ; crops 77 pixels from upper and lower side of bitmap rectangle. Does not dispose of pBitmap. */ Gdip_CloneBitmap(pBitmap) { ; returns cloned (duplicated) bitmap. By Learning one. Gdip_GetDimensions(pBitmap, w, h), pClonedBitmap := Gdip_CloneBitmapArea(pBitmap, 0, 0, w, h) return pClonedBitmap } /* ;Example: pClonedBitmap := Gdip_CloneBitmap(pBitmap) ; clones (duplicates) bitmap. */