Ticket #8048: Tracker_even_larger_icons_1.diff
File Tracker_even_larger_icons_1.diff, 8.1 KB (added by , 13 years ago) |
---|
-
src/kits/tracker/ContainerWindow.cpp
diff --git src/kits/tracker/ContainerWindow.cpp src/kits/tracker/ContainerWindow.cpp index fb065e8..d8d517d 100644
BContainerWindow::AddWindowMenu(BMenu *menu) 1949 1949 item->SetTarget(PoseView()); 1950 1950 iconSizeMenu->AddItem(item); 1951 1951 1952 message = new BMessage(kIconMode); 1953 message->AddInt32("size", 96); 1954 item = new BMenuItem(B_TRANSLATE("96 x 96"), message); 1955 item->SetMarked(PoseView()->IconSizeInt() == 96); 1956 item->SetTarget(PoseView()); 1957 iconSizeMenu->AddItem(item); 1958 1959 message = new BMessage(kIconMode); 1960 message->AddInt32("size", 128); 1961 item = new BMenuItem(B_TRANSLATE("128 x 128"), message); 1962 item->SetMarked(PoseView()->IconSizeInt() == 128); 1963 item->SetTarget(PoseView()); 1964 iconSizeMenu->AddItem(item); 1965 1952 1966 iconSizeMenu->AddSeparatorItem(); 1953 1967 1954 1968 message = new BMessage(kIconMode); -
src/kits/tracker/DeskWindow.cpp
diff --git src/kits/tracker/DeskWindow.cpp src/kits/tracker/DeskWindow.cpp index 9ec3db4..85545db 100644
BDeskWindow::AddWindowContextMenus(BMenu *menu) 309 309 item->SetTarget(PoseView()); 310 310 iconSizeMenu->AddItem(item); 311 311 312 message = new BMessage(kIconMode); 313 message->AddInt32("size", 96); 314 item = new BMenuItem(B_TRANSLATE("96 x 96"), message); 315 item->SetMarked(PoseView()->IconSizeInt() == 96); 316 item->SetTarget(PoseView()); 317 iconSizeMenu->AddItem(item); 318 319 message = new BMessage(kIconMode); 320 message->AddInt32("size", 128); 321 item = new BMenuItem(B_TRANSLATE("128 x 128"), message); 322 item->SetMarked(PoseView()->IconSizeInt() == 128); 323 item->SetTarget(PoseView()); 324 iconSizeMenu->AddItem(item); 325 312 326 iconSizeMenu->AddSeparatorItem(); 313 327 314 328 message = new BMessage(kIconMode); -
src/kits/tracker/PoseView.cpp
diff --git src/kits/tracker/PoseView.cpp src/kits/tracker/PoseView.cpp index d5f6543..267e026 100644
BPoseView::MessageReceived(BMessage *message) 2133 2133 case 64: 2134 2134 fViewState->SetIconSize(48); 2135 2135 break; 2136 case 96: 2137 fViewState->SetIconSize(64); 2138 break; 2139 case 128: 2140 fViewState->SetIconSize(96); 2141 break; 2136 2142 } 2137 2143 } else if (scale == 1 && (int32)IconSizeInt() != 128) { 2138 2144 switch ((int32)IconSizeInt()) { … … BPoseView::MessageReceived(BMessage *message) 2145 2151 case 48: 2146 2152 fViewState->SetIconSize(64); 2147 2153 break; 2154 case 64: 2155 fViewState->SetIconSize(96); 2156 break; 2157 case 96: 2158 fViewState->SetIconSize(128); 2159 break; 2148 2160 } 2149 2161 } 2150 2162 } else { 2151 2163 int32 iconSize = fViewState->LastIconSize(); 2152 if (iconSize < 32 || iconSize > 64) {2164 if (iconSize < 32 || iconSize > 128) { 2153 2165 // uninitialized last icon size? 2154 2166 iconSize = 32; 2155 2167 } -
src/kits/tracker/ViewState.cpp
diff --git src/kits/tracker/ViewState.cpp src/kits/tracker/ViewState.cpp index 20fc4d5..533676d 100644
BViewState::_Sanitize(BViewState *state, bool fixOnly) 474 474 } 475 475 if (state->fIconSize < 16) 476 476 state->fIconSize = 16; 477 if (state->fIconSize > 64)478 state->fIconSize = 64;477 if (state->fIconSize > 128) 478 state->fIconSize = 128; 479 479 if (state->fLastIconSize < 16) 480 480 state->fLastIconSize = 16; 481 if (state->fLastIconSize > 64)482 state->fLastIconSize = 64;481 if (state->fLastIconSize > 128) 482 state->fLastIconSize = 128; 483 483 484 484 if (fixOnly) 485 485 return state; -
src/libs/icon/IconUtils.cpp
diff --git src/libs/icon/IconUtils.cpp src/libs/icon/IconUtils.cpp index c67a64e..aeac458 100644
scale2x(const uint8* srcBits, uint8* dstBits, int32 srcWidth, int32 srcHeight, 145 145 } 146 146 147 147 148 static void 149 scale3x(const uint8* srcBits, uint8* dstBits, int32 srcWidth, int32 srcHeight, 150 int32 srcBPR, int32 dstBPR) 151 { 152 /* 153 * This implements the AdvanceMAME Scale3x algorithm found on: 154 * http://scale2x.sourceforge.net/ 155 * 156 * It is an incredibly simple and powerful image tripling routine that does 157 * an astonishing job of tripling game graphic data while interpolating out 158 * the jaggies. 159 * 160 * Derived from the (public domain) SDL version of the library by Pete 161 * Shinners 162 */ 163 164 // Assume that both src and dst are 4 BPP (B_RGBA32) 165 for(int32 y = 0; y < srcHeight; ++y) 166 { 167 for(int32 x = 0; x < srcWidth; ++x) 168 { 169 uint32 a = *(uint32*)(srcBits + (MAX(0, y - 1) * srcBPR) 170 + (4 * MAX(0, x - 1))); 171 uint32 b = *(uint32*)(srcBits + (MAX(0, y - 1) * srcBPR) 172 + (4 * x)); 173 uint32 c = *(uint32*)(srcBits + (MAX(0, y - 1) * srcBPR) 174 + (4 * MIN(srcWidth - 1, x + 1))); 175 uint32 d = *(uint32*)(srcBits + (y * srcBPR) 176 + (4 * MAX(0, x - 1))); 177 uint32 e = *(uint32*)(srcBits + (y * srcBPR) 178 + (4 * x)); 179 uint32 f = *(uint32*)(srcBits + (y * srcBPR) 180 + (4 * MIN(srcWidth - 1,x + 1))); 181 uint32 g = *(uint32*)(srcBits + (MIN(srcHeight - 1, y + 1) 182 * srcBPR) + (4 * MAX(0, x - 1))); 183 uint32 h = *(uint32*)(srcBits + (MIN(srcHeight - 1, y + 1) 184 * srcBPR) + (4 * x)); 185 uint32 i = *(uint32*)(srcBits + (MIN(srcHeight - 1, y + 1) 186 * srcBPR) + (4 * MIN(srcWidth - 1, x + 1))); 187 188 uint32 e0 = d == b && b != f && d != h ? d : e; 189 uint32 e1 = (d == b && b != f && d != h && e != c) 190 || (b == f && b != d && f != h && e != a) ? b : e; 191 uint32 e2 = b == f && b != d && f != h ? f : e; 192 uint32 e3 = (d == b && b != f && d != h && e != g) 193 || (d == b && b != f && d != h && e != a) ? d : e; 194 uint32 e4 = e; 195 uint32 e5 = (b == f && b != d && f != h && e != i) 196 || (h == f && d != h && b != f && e != c) ? f : e; 197 uint32 e6 = d == h && d != b && h != f ? d : e; 198 uint32 e7 = (d == h && d != b && h != f && e != i) 199 || (h == f && d != h && b != f && e != g) ? h : e; 200 uint32 e8 = h == f && d != h && b != f ? f : e; 201 202 *(uint32*)(dstBits + y * 3 * dstBPR + x * 3 * 4) = e0; 203 *(uint32*)(dstBits + y * 3 * dstBPR + (x * 3 + 1) * 4) = e1; 204 *(uint32*)(dstBits + y * 3 * dstBPR + (x * 3 + 2) * 4) = e2; 205 *(uint32*)(dstBits + (y * 3 + 1) * dstBPR + x * 3 * 4) = e3; 206 *(uint32*)(dstBits + (y * 3 + 1) * dstBPR + (x * 3 + 1) * 4) = e4; 207 *(uint32*)(dstBits + (y * 3 + 1) * dstBPR + (x * 3 + 2) * 4) = e5; 208 *(uint32*)(dstBits + (y * 3 + 2) * dstBPR + x * 3 * 4) = e6; 209 *(uint32*)(dstBits + (y * 3 + 2) * dstBPR + (x * 3 + 1) * 4) = e7; 210 *(uint32*)(dstBits + (y * 3 + 2) * dstBPR + (x * 3 + 2) * 4) = e8; 211 } 212 } 213 } 214 215 216 static void 217 scale4x(const uint8* srcBits, uint8* dstBits, int32 srcWidth, int32 srcHeight, 218 int32 srcBPR, int32 dstBPR) 219 { 220 // scale4x is just scale2x twice 221 BBitmap* tmp = new BBitmap(BRect(0, 0, srcWidth * 2 - 1, 222 srcHeight * 2 - 1), B_RGBA32); 223 uint8* tmpBits = (uint8*)tmp->Bits(); 224 int32 tmpBPR = tmp->BytesPerRow(); 225 226 scale2x(srcBits, tmpBits, srcWidth, srcHeight, srcBPR, tmpBPR); 227 scale2x(tmpBits, dstBits, srcWidth * 2, srcHeight * 2, tmpBPR, dstBPR); 228 229 delete tmp; 230 } 231 232 148 233 // #pragma mark - 149 234 150 235 … … BIconUtils::ConvertFromCMAP8(const uint8* src, uint32 width, uint32 height, 535 620 uint8* convertedBits = (uint8*)converted->Bits(); 536 621 int32 convertedBPR = converted->BytesPerRow(); 537 622 scale2x(convertedBits, dst, width, height, convertedBPR, dstBPR); 623 } else if (dstWidth == 3 * width && dstHeight == 3 * height) { 624 // scale using the scale3x algorithm 625 BBitmap* converted = new BBitmap(BRect(0, 0, width - 1, height - 1), 626 result->ColorSpace()); 627 converted->ImportBits(src, height * srcBPR, srcBPR, 0, B_CMAP8); 628 uint8* convertedBits = (uint8*)converted->Bits(); 629 int32 convertedBPR = converted->BytesPerRow(); 630 scale3x(convertedBits, dst, width, height, convertedBPR, dstBPR); 631 } else if (dstWidth == 4 * width && dstHeight == 4 * height) { 632 // scale using the scale4x algorithm 633 BBitmap* converted = new BBitmap(BRect(0, 0, width - 1, height - 1), 634 result->ColorSpace()); 635 converted->ImportBits(src, height * srcBPR, srcBPR, 0, B_CMAP8); 636 uint8* convertedBits = (uint8*)converted->Bits(); 637 int32 convertedBPR = converted->BytesPerRow(); 638 scale4x(convertedBits, dst, width, height, convertedBPR, dstBPR); 538 639 } else { 539 640 // bilinear scaling 540 641 scale_bilinear(dst, width, height, dstWidth, dstHeight, dstBPR);