diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-07 22:07:22 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-07 22:07:22 +0000 |
commit | 033e0683934e31341a9a28ae1a7fac17fba9215f (patch) | |
tree | d0bf3a05c7a23241ba013b4f5df8aede2b2f1ec3 /plugins/Clist_modern/src/modern_cachefuncs.cpp | |
parent | 8726be3602d129ce335752d5fe036c6872d695a6 (diff) |
suddenly © clist modern contained code to process avatars manually, besides AVS
git-svn-id: http://svn.miranda-ng.org/main/trunk@13483 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern/src/modern_cachefuncs.cpp')
-rw-r--r-- | plugins/Clist_modern/src/modern_cachefuncs.cpp | 114 |
1 files changed, 12 insertions, 102 deletions
diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index 0a6bf05fed..fc827e024a 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -723,13 +723,9 @@ void Cache_ProceedAvatarInList(ClcData *dat, ClcContact *contact) } else if (contact->avatar_data->hbmPic != NULL) //Lets Add it { - // Make bounds -> keep aspect radio - LONG width_clip; - LONG height_clip; - // Clipping width and height - width_clip = dat->avatars_maxwidth_size ? dat->avatars_maxwidth_size : dat->avatars_maxheight_size; - height_clip = dat->avatars_maxheight_size; + LONG width_clip = dat->avatars_maxwidth_size ? dat->avatars_maxwidth_size : dat->avatars_maxheight_size; + LONG height_clip = dat->avatars_maxheight_size; if (height_clip * ace->bmWidth / ace->bmHeight <= width_clip) width_clip = height_clip * ace->bmWidth / ace->bmHeight; @@ -778,108 +774,22 @@ void Cache_ProceedAvatarInList(ClcData *dat, ClcContact *contact) void Cache_GetAvatar(ClcData *dat, ClcContact *contact) { - int old_pos = contact->avatar_pos; - // workaround for avatar service and other wich destroys service on OK_TOEXIT - if (g_CluiData.bSTATE != STATE_NORMAL || (dat->use_avatar_service && !ServiceExists(MS_AV_GETAVATARBITMAP))) { + // workaround for avatar service + if (g_CluiData.bSTATE != STATE_NORMAL) { contact->avatar_pos = AVATAR_POS_DONT_HAVE; contact->avatar_data = NULL; return; } - if (dat->use_avatar_service && ServiceExists(MS_AV_GETAVATARBITMAP)) { - if (dat->avatars_show && !db_get_b(contact->hContact, "CList", "HideContactAvatar", 0)) { - contact->avatar_data = (struct avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)contact->hContact, 0); - if (contact->avatar_data == NULL || contact->avatar_data->cbSize != sizeof(struct avatarCacheEntry) || contact->avatar_data->dwFlags == AVS_BITMAP_EXPIRED) - contact->avatar_data = NULL; - - if (contact->avatar_data != NULL) - contact->avatar_data->t_lastAccess = (DWORD)time(NULL); - } - else contact->avatar_data = NULL; + if (dat->avatars_show && !db_get_b(contact->hContact, "CList", "HideContactAvatar", 0)) { + contact->avatar_data = (struct avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)contact->hContact, 0); + if (contact->avatar_data == NULL || contact->avatar_data->cbSize != sizeof(struct avatarCacheEntry) || contact->avatar_data->dwFlags == AVS_BITMAP_EXPIRED) + contact->avatar_data = NULL; - Cache_ProceedAvatarInList(dat, contact); + if (contact->avatar_data != NULL) + contact->avatar_data->t_lastAccess = (DWORD)time(NULL); } - else { - contact->avatar_pos = AVATAR_POS_DONT_HAVE; - if (dat->avatars_show && !db_get_b(contact->hContact, "CList", "HideContactAvatar", 0)) { - DBVARIANT dbv; - if (!db_get_ts(contact->hContact, "ContactPhoto", "File", &dbv)) { - HBITMAP hBmp = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (LPARAM)dbv.ptszVal); - if (hBmp != NULL) { - // Make bounds - BITMAP bm; - if (GetObject(hBmp, sizeof(BITMAP), &bm)) { - // Create data... - HDC hdc; - HBITMAP hDrawBmp, oldBmp; - - // Make bounds -> keep aspect radio - LONG width_clip; - LONG height_clip; - RECT rc = { 0 }; - - // Clipping width and height - width_clip = dat->avatars_maxheight_size; - height_clip = dat->avatars_maxheight_size; - - if (height_clip * bm.bmWidth / bm.bmHeight <= width_clip) - width_clip = height_clip * bm.bmWidth / bm.bmHeight; - else - height_clip = width_clip * bm.bmHeight / bm.bmWidth; - - // Create objs - hdc = CreateCompatibleDC(dat->avatar_cache.hdc); - hDrawBmp = ske_CreateDIB32(width_clip, height_clip); - oldBmp = (HBITMAP)SelectObject(hdc, hDrawBmp); - SetBkMode(hdc, TRANSPARENT); - - POINT org; - GetBrushOrgEx(hdc, &org); - SetStretchBltMode(hdc, HALFTONE); - SetBrushOrgEx(hdc, org.x, org.y, NULL); - - rc.right = width_clip - 1; - rc.bottom = height_clip - 1; - - // Draw bitmap 8//8 - HDC dcMem = CreateCompatibleDC(hdc); - HBITMAP obmp = (HBITMAP)SelectObject(dcMem, hBmp); - StretchBlt(hdc, 0, 0, width_clip, height_clip, dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); - SelectObject(dcMem, obmp); - DeleteDC(dcMem); - - RECT rtr = { 0 }; - rtr.right = width_clip + 1; - rtr.bottom = height_clip + 1; - ske_SetRectOpaque(hdc, &rtr); - - hDrawBmp = (HBITMAP)GetCurrentObject(hdc, OBJ_BITMAP); - SelectObject(hdc, oldBmp); - DeleteDC(hdc); - - // Add to list - if (old_pos >= 0) { - ImageArray_ChangeImage(&dat->avatar_cache, hDrawBmp, old_pos); - contact->avatar_pos = old_pos; - } - else contact->avatar_pos = ImageArray_AddImage(&dat->avatar_cache, hDrawBmp, -1); - - DeleteObject(hDrawBmp); - } // if (GetObject(hBmp,sizeof(BITMAP),&bm)) - DeleteObject(hBmp); - } //if (hBmp != NULL) - db_free(&dbv); - } - } + else contact->avatar_data = NULL; - // Remove avatar if needed - if (old_pos >= 0 && contact->avatar_pos == AVATAR_POS_DONT_HAVE) { - ImageArray_RemoveImage(&dat->avatar_cache, old_pos); - // Update all items - ExecuteOnAllContacts(dat, ReduceAvatarPosition, (void *)&old_pos); - } - - if (old_pos == AVATAR_POS_ANIMATED && contact->avatar_pos != AVATAR_POS_ANIMATED) - AniAva_RemoveAvatar(contact->hContact); - } + Cache_ProceedAvatarInList(dat, contact); } |