@@ -826,7 +826,7 @@ void osimage_frame(const OSImage *image, const uint32_t frame_index, real32_t *f
826826
827827/* ---------------------------------------------------------------------------*/
828828
829- void *osimage_bitmap (const OSImage *osimage)
829+ const void *osimage_native (const OSImage *osimage)
830830{
831831 cassert_no_null (osimage);
832832 return osimage->bitmap ;
@@ -836,12 +836,11 @@ void *osimage_bitmap(const OSImage *osimage)
836836
837837HBITMAP osimage_hbitmap (const Image *image, COLORREF background)
838838{
839- OSImage *osimage = (OSImage *)image_native (image);
839+ Gdiplus::Bitmap *bitmap = (Gdiplus::Bitmap *)image_native (image);
840840 Gdiplus::Color c;
841841 HBITMAP hbitmap;
842- cassert_no_null (osimage);
843842 c.SetFromCOLORREF (background);
844- Gdiplus::Status status = osimage-> bitmap ->GetHBITMAP (c, &hbitmap);
843+ Gdiplus::Status status = bitmap->GetHBITMAP (c, &hbitmap);
845844 cassert_unref (status == Gdiplus::Ok, status);
846845 return hbitmap;
847846}
@@ -850,25 +849,25 @@ HBITMAP osimage_hbitmap(const Image *image, COLORREF background)
850849
851850HBITMAP osimage_hbitmap_cache (const Image *image, COLORREF background, LONG *width, LONG *height)
852851{
853- OSImage *osimage = (OSImage*) image_native (image);
852+ const OSImage *osimage = osimage_from_image (image);
854853 cassert_no_null (osimage);
855854
856855 if (osimage->hbitmap != NULL && osimage->hbitmap_background != background)
857856 {
858857 BOOL ret = DeleteObject (osimage->hbitmap );
859858 cassert_unref (ret != 0 , ret);
860- osimage->hbitmap = NULL ;
859+ ((OSImage*) osimage) ->hbitmap = NULL ;
861860 }
862861
863862 if (osimage->hbitmap == NULL )
864863 {
865864 BITMAP bm;
866865 HBITMAP hbitmap = osimage_hbitmap (image, background);
867- osimage->hbitmap = hbitmap;
866+ ((OSImage*) osimage) ->hbitmap = hbitmap;
868867 GetObject (hbitmap, sizeof (bm), &bm);
869- osimage->hbitmap_width = bm.bmWidth ;
870- osimage->hbitmap_height = bm.bmHeight ;
871- osimage->hbitmap_background = background;
868+ ((OSImage*) osimage) ->hbitmap_width = bm.bmWidth ;
869+ ((OSImage*) osimage) ->hbitmap_height = bm.bmHeight ;
870+ ((OSImage*) osimage) ->hbitmap_background = background;
872871 }
873872
874873 *width = osimage->hbitmap_width ;
@@ -954,12 +953,12 @@ HCURSOR osimage_hcursor(const Image *image, const uint32_t hot_x, const uint32_t
954953{
955954 // HCURSOR direct from Gdiplus::Bitmap ;-)
956955 // http://csharphelper.com/blog/2017/01/convert-a-bitmap-into-a-cursor-in-c/
957- OSImage *osimage = (OSImage *)image_native (image);
956+ Gdiplus::Bitmap *bitmap = (Gdiplus::Bitmap *)image_native (image);
958957 HICON icon = NULL ;
959958 ICONINFO info;
960959 HCURSOR hcursor = NULL ;
961960 BOOL ret = FALSE ;
962- Gdiplus::Status st = osimage-> bitmap ->GetHICON (&icon);
961+ Gdiplus::Status st = bitmap->GetHICON (&icon);
963962 cassert_unref (st == Gdiplus::Ok, st);
964963 GetIconInfo (icon, &info);
965964 info.xHotspot = (DWORD)hot_x;
@@ -979,12 +978,12 @@ HCURSOR osimage_hcursor(const Image *image, const uint32_t hot_x, const uint32_t
979978
980979void osimage_draw (const Image *image, HDC hdc, const uint32_t frame_index, const real32_t x, const real32_t y, const real32_t width, const real32_t height, const BOOL gray)
981980{
982- OSImage *osimage = (OSImage *)image_native (image);
981+ Gdiplus::Bitmap *bitmap = (Gdiplus::Bitmap *)image_native (image);
983982 Gdiplus::Graphics graphics (hdc);
984983
985984 if (frame_index != UINT32_MAX)
986985 {
987- Gdiplus::Status status = osimage-> bitmap ->SelectActiveFrame (&Gdiplus::FrameDimensionTime, (UINT)frame_index);
986+ Gdiplus::Status status = bitmap->SelectActiveFrame (&Gdiplus::FrameDimensionTime, (UINT)frame_index);
988987 cassert_unref (status == Gdiplus::Ok, status);
989988 }
990989
@@ -1051,10 +1050,10 @@ void osimage_draw(const Image *image, HDC hdc, const uint32_t frame_index, const
10511050 Gdiplus::ImageAttributes attr;
10521051 Gdiplus::RectF rect ((Gdiplus::REAL)x, (Gdiplus::REAL)y, (Gdiplus::REAL)width, (Gdiplus::REAL)height);
10531052 attr.SetColorMatrix (&matrix, Gdiplus::ColorMatrixFlagsDefault, Gdiplus::ColorAdjustTypeBitmap);
1054- graphics.DrawImage (osimage-> bitmap , rect, (Gdiplus::REAL)0 , (Gdiplus::REAL)0 , (Gdiplus::REAL)width, (Gdiplus::REAL)height, Gdiplus::UnitPixel, &attr);
1053+ graphics.DrawImage (bitmap, rect, (Gdiplus::REAL)0 , (Gdiplus::REAL)0 , (Gdiplus::REAL)width, (Gdiplus::REAL)height, Gdiplus::UnitPixel, &attr);
10551054 }
10561055 else
10571056 {
1058- graphics.DrawImage (osimage-> bitmap , (Gdiplus::REAL)x, (Gdiplus::REAL)y, (Gdiplus::REAL)width, (Gdiplus::REAL)height);
1057+ graphics.DrawImage (bitmap, (Gdiplus::REAL)x, (Gdiplus::REAL)y, (Gdiplus::REAL)width, (Gdiplus::REAL)height);
10591058 }
10601059}
0 commit comments