File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,11 @@ double Costume::bitmapResolution() const
2626/* ! Sets the reciprocal of the costume scaling factor for bitmap costumes. */
2727void Costume::setBitmapResolution (double newBitmapResolution)
2828{
29+ if (impl->bitmapResolution == newBitmapResolution)
30+ return ;
31+
2932 impl->bitmapResolution = newBitmapResolution;
33+ impl->updateImage ();
3034}
3135
3236/* ! Returns the x-coordinate of the rotation center. */
@@ -56,13 +60,13 @@ void Costume::setRotationCenterY(int newRotationCenterY)
5660/* ! Returns the costume width. */
5761unsigned int Costume::width () const
5862{
59- return impl->image ->width () * impl->scale ;
63+ return impl->image ->width () * impl->scale / impl-> bitmapResolution ;
6064}
6165
6266/* ! Returns the costume height. */
6367unsigned int Costume::height () const
6468{
65- return impl->image ->height () * impl->scale ;
69+ return impl->image ->height () * impl->scale / impl-> bitmapResolution ;
6670}
6771
6872/* ! Returns the image scale. */
Original file line number Diff line number Diff line change @@ -16,29 +16,30 @@ CostumePrivate::~CostumePrivate()
1616
1717void CostumePrivate::updateImage ()
1818{
19- unsigned int scaledWidth = image->width () * scale;
20- unsigned int scaledHeight = image->height () * scale;
19+ unsigned int scaledWidth = image->width () * scale / bitmapResolution ;
20+ unsigned int scaledHeight = image->height () * scale / bitmapResolution ;
2121
2222 if (scaledWidth == 0 || scaledHeight == 0 ) {
2323 freeImage ();
2424 return ;
2525 }
2626
27- if (!bitmap || (scale != oldScale)) {
27+ if (!bitmap || (scale != oldScale) || (bitmapResolution != oldBitmapResolution) ) {
2828 freeImage ();
2929 bitmap = static_cast <Rgb **>(malloc (sizeof (Rgb *) * scaledHeight));
3030
3131 for (unsigned int i = 0 ; i < scaledHeight; i++)
3232 bitmap[i] = static_cast <Rgb *>(malloc (sizeof (Rgb) * scaledWidth));
3333
3434 oldScale = scale;
35+ oldBitmapResolution = bitmapResolution;
3536 oldWidth = scaledWidth;
3637 oldHeight = scaledHeight;
3738 }
3839
3940 for (unsigned int i = 0 ; i < scaledHeight; i++) {
4041 for (unsigned int j = 0 ; j < scaledWidth; j++) {
41- Rgb color = image->colorAt (mirrorHorizontally ? (scaledWidth - 1 - j) : j, i, scale);
42+ Rgb color = image->colorAt (mirrorHorizontally ? (scaledWidth - 1 - j) : j, i, scale / bitmapResolution );
4243
4344 // TODO: Apply graphics effects here
4445
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ struct CostumePrivate
1919 void updateImage ();
2020 void freeImage ();
2121
22+ double oldBitmapResolution = 1 ;
2223 double bitmapResolution = 1 ;
2324 int rotationCenterX = 0 ;
2425 int rotationCenterY = 0 ;
You can’t perform that action at this time.
0 commit comments