Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: core/fxge/win32/fx_win32_gdipext.cpp

Issue 2477443002: Remove FX_BOOL from core (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxge/win32/fx_win32_dwrite.cpp ('k') | core/fxge/win32/fx_win32_print.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 uint32_t size, 439 uint32_t size,
440 void* pdv, 440 void* pdv,
441 uint32_t* num_face) { 441 uint32_t* num_face) {
442 if (!m_pGdiAddFontMemResourceEx) 442 if (!m_pGdiAddFontMemResourceEx)
443 return nullptr; 443 return nullptr;
444 444
445 return m_pGdiAddFontMemResourceEx((PVOID)pFontdata, (DWORD)size, (PVOID)pdv, 445 return m_pGdiAddFontMemResourceEx((PVOID)pFontdata, (DWORD)size, (PVOID)pdv,
446 (DWORD*)num_face); 446 (DWORD*)num_face);
447 } 447 }
448 448
449 FX_BOOL CGdiplusExt::GdiRemoveFontMemResourceEx(void* handle) { 449 bool CGdiplusExt::GdiRemoveFontMemResourceEx(void* handle) {
450 return m_pGdiRemoveFontMemResourseEx && 450 return m_pGdiRemoveFontMemResourseEx &&
451 m_pGdiRemoveFontMemResourseEx((HANDLE)handle); 451 m_pGdiRemoveFontMemResourseEx((HANDLE)handle);
452 } 452 }
453 453
454 static GpBrush* _GdipCreateBrush(DWORD argb) { 454 static GpBrush* _GdipCreateBrush(DWORD argb) {
455 CGdiplusExt& GdiplusExt = 455 CGdiplusExt& GdiplusExt =
456 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 456 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
457 GpSolidFill* solidBrush = nullptr; 457 GpSolidFill* solidBrush = nullptr;
458 CallFunc(GdipCreateSolidFill)((ARGB)argb, &solidBrush); 458 CallFunc(GdipCreateSolidFill)((ARGB)argb, &solidBrush);
459 return solidBrush; 459 return solidBrush;
460 } 460 }
461 static CFX_DIBitmap* _StretchMonoToGray(int dest_width, 461 static CFX_DIBitmap* _StretchMonoToGray(int dest_width,
462 int dest_height, 462 int dest_height,
463 const CFX_DIBitmap* pSource, 463 const CFX_DIBitmap* pSource,
464 FX_RECT* pClipRect) { 464 FX_RECT* pClipRect) {
465 FX_BOOL bFlipX = dest_width < 0; 465 bool bFlipX = dest_width < 0;
466 if (bFlipX) { 466 if (bFlipX) {
467 dest_width = -dest_width; 467 dest_width = -dest_width;
468 } 468 }
469 FX_BOOL bFlipY = dest_height < 0; 469 bool bFlipY = dest_height < 0;
470 if (bFlipY) { 470 if (bFlipY) {
471 dest_height = -dest_height; 471 dest_height = -dest_height;
472 } 472 }
473 int result_width = pClipRect->Width(); 473 int result_width = pClipRect->Width();
474 int result_height = pClipRect->Height(); 474 int result_height = pClipRect->Height();
475 int result_pitch = (result_width + 3) / 4 * 4; 475 int result_pitch = (result_width + 3) / 4 * 4;
476 CFX_DIBitmap* pStretched = new CFX_DIBitmap; 476 CFX_DIBitmap* pStretched = new CFX_DIBitmap;
477 if (!pStretched->Create(result_width, result_height, FXDIB_8bppRgb)) { 477 if (!pStretched->Create(result_width, result_height, FXDIB_8bppRgb)) {
478 delete pStretched; 478 delete pStretched;
479 return nullptr; 479 return nullptr;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 if (image_clip.IsEmpty()) { 557 if (image_clip.IsEmpty()) {
558 return; 558 return;
559 } 559 }
560 image_clip.Offset(-image_rect.left, -image_rect.top); 560 image_clip.Offset(-image_rect.left, -image_rect.top);
561 CFX_DIBitmap* pStretched = nullptr; 561 CFX_DIBitmap* pStretched = nullptr;
562 if (src_width * src_height > 10000) { 562 if (src_width * src_height > 10000) {
563 pStretched = 563 pStretched =
564 _StretchMonoToGray(dest_width, dest_height, pBitmap, &image_clip); 564 _StretchMonoToGray(dest_width, dest_height, pBitmap, &image_clip);
565 } else { 565 } else {
566 pStretched = 566 pStretched =
567 pBitmap->StretchTo(dest_width, dest_height, FALSE, &image_clip); 567 pBitmap->StretchTo(dest_width, dest_height, false, &image_clip);
568 } 568 }
569 GpBitmap* bitmap; 569 GpBitmap* bitmap;
570 CallFunc(GdipCreateBitmapFromScan0)(image_clip.Width(), image_clip.Height(), 570 CallFunc(GdipCreateBitmapFromScan0)(image_clip.Width(), image_clip.Height(),
571 (image_clip.Width() + 3) / 4 * 4, 571 (image_clip.Width() + 3) / 4 * 4,
572 PixelFormat8bppIndexed, 572 PixelFormat8bppIndexed,
573 pStretched->GetBuffer(), &bitmap); 573 pStretched->GetBuffer(), &bitmap);
574 int a, r, g, b; 574 int a, r, g, b;
575 ArgbDecode(argb, a, r, g, b); 575 ArgbDecode(argb, a, r, g, b);
576 UINT pal[258]; 576 UINT pal[258];
577 pal[0] = 0; 577 pal[0] = 0;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 return pCollection; 722 return pCollection;
723 } 723 }
724 CallFunc(GdipDeletePrivateFontCollection)(&pCollection); 724 CallFunc(GdipDeletePrivateFontCollection)(&pCollection);
725 return nullptr; 725 return nullptr;
726 } 726 }
727 void CGdiplusExt::DeleteMemFont(LPVOID pCollection) { 727 void CGdiplusExt::DeleteMemFont(LPVOID pCollection) {
728 CGdiplusExt& GdiplusExt = 728 CGdiplusExt& GdiplusExt =
729 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 729 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
730 CallFunc(GdipDeletePrivateFontCollection)((GpFontCollection**)&pCollection); 730 CallFunc(GdipDeletePrivateFontCollection)((GpFontCollection**)&pCollection);
731 } 731 }
732 FX_BOOL CGdiplusExt::GdipCreateBitmap(CFX_DIBitmap* pBitmap, void** bitmap) { 732 bool CGdiplusExt::GdipCreateBitmap(CFX_DIBitmap* pBitmap, void** bitmap) {
733 CGdiplusExt& GdiplusExt = 733 CGdiplusExt& GdiplusExt =
734 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 734 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
735 PixelFormat format; 735 PixelFormat format;
736 switch (pBitmap->GetFormat()) { 736 switch (pBitmap->GetFormat()) {
737 case FXDIB_Rgb: 737 case FXDIB_Rgb:
738 format = PixelFormat24bppRGB; 738 format = PixelFormat24bppRGB;
739 break; 739 break;
740 case FXDIB_Rgb32: 740 case FXDIB_Rgb32:
741 format = PixelFormat32bppRGB; 741 format = PixelFormat32bppRGB;
742 break; 742 break;
743 case FXDIB_Argb: 743 case FXDIB_Argb:
744 format = PixelFormat32bppARGB; 744 format = PixelFormat32bppARGB;
745 break; 745 break;
746 default: 746 default:
747 return FALSE; 747 return false;
748 } 748 }
749 GpStatus status = CallFunc(GdipCreateBitmapFromScan0)( 749 GpStatus status = CallFunc(GdipCreateBitmapFromScan0)(
750 pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap->GetPitch(), format, 750 pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap->GetPitch(), format,
751 pBitmap->GetBuffer(), (GpBitmap**)bitmap); 751 pBitmap->GetBuffer(), (GpBitmap**)bitmap);
752 if (status == Ok) { 752 if (status == Ok) {
753 return TRUE; 753 return true;
754 } 754 }
755 return FALSE; 755 return false;
756 } 756 }
757 FX_BOOL CGdiplusExt::GdipCreateFromImage(void* bitmap, void** graphics) { 757 bool CGdiplusExt::GdipCreateFromImage(void* bitmap, void** graphics) {
758 CGdiplusExt& GdiplusExt = 758 CGdiplusExt& GdiplusExt =
759 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 759 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
760 GpStatus status = CallFunc(GdipGetImageGraphicsContext)( 760 GpStatus status = CallFunc(GdipGetImageGraphicsContext)(
761 (GpBitmap*)bitmap, (GpGraphics**)graphics); 761 (GpBitmap*)bitmap, (GpGraphics**)graphics);
762 if (status == Ok) { 762 if (status == Ok) {
763 return TRUE; 763 return true;
764 } 764 }
765 return FALSE; 765 return false;
766 } 766 }
767 FX_BOOL CGdiplusExt::GdipCreateFontFamilyFromName(const FX_WCHAR* name, 767 bool CGdiplusExt::GdipCreateFontFamilyFromName(const FX_WCHAR* name,
768 void* pFontCollection, 768 void* pFontCollection,
769 void** pFamily) { 769 void** pFamily) {
770 CGdiplusExt& GdiplusExt = 770 CGdiplusExt& GdiplusExt =
771 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 771 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
772 GpStatus status = CallFunc(GdipCreateFontFamilyFromName)( 772 GpStatus status = CallFunc(GdipCreateFontFamilyFromName)(
773 (GDIPCONST WCHAR*)name, (GpFontCollection*)pFontCollection, 773 (GDIPCONST WCHAR*)name, (GpFontCollection*)pFontCollection,
774 (GpFontFamily**)pFamily); 774 (GpFontFamily**)pFamily);
775 if (status == Ok) { 775 if (status == Ok) {
776 return TRUE; 776 return true;
777 } 777 }
778 return FALSE; 778 return false;
779 } 779 }
780 FX_BOOL CGdiplusExt::GdipCreateFontFromFamily(void* pFamily, 780 bool CGdiplusExt::GdipCreateFontFromFamily(void* pFamily,
781 FX_FLOAT font_size, 781 FX_FLOAT font_size,
782 int fontstyle, 782 int fontstyle,
783 int flag, 783 int flag,
784 void** pFont) { 784 void** pFont) {
785 CGdiplusExt& GdiplusExt = 785 CGdiplusExt& GdiplusExt =
786 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 786 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
787 GpStatus status = 787 GpStatus status =
788 CallFunc(GdipCreateFont)((GpFontFamily*)pFamily, font_size, fontstyle, 788 CallFunc(GdipCreateFont)((GpFontFamily*)pFamily, font_size, fontstyle,
789 Unit(flag), (GpFont**)pFont); 789 Unit(flag), (GpFont**)pFont);
790 if (status == Ok) { 790 if (status == Ok) {
791 return TRUE; 791 return true;
792 } 792 }
793 return FALSE; 793 return false;
794 } 794 }
795 void CGdiplusExt::GdipGetFontSize(void* pFont, FX_FLOAT* size) { 795 void CGdiplusExt::GdipGetFontSize(void* pFont, FX_FLOAT* size) {
796 REAL get_size; 796 REAL get_size;
797 CGdiplusExt& GdiplusExt = 797 CGdiplusExt& GdiplusExt =
798 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 798 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
799 GpStatus status = CallFunc(GdipGetFontSize)((GpFont*)pFont, (REAL*)&get_size); 799 GpStatus status = CallFunc(GdipGetFontSize)((GpFont*)pFont, (REAL*)&get_size);
800 if (status == Ok) { 800 if (status == Ok) {
801 *size = (FX_FLOAT)get_size; 801 *size = (FX_FLOAT)get_size;
802 } else { 802 } else {
803 *size = 0; 803 *size = 0;
804 } 804 }
805 } 805 }
806 void CGdiplusExt::GdipSetTextRenderingHint(void* graphics, int mode) { 806 void CGdiplusExt::GdipSetTextRenderingHint(void* graphics, int mode) {
807 CGdiplusExt& GdiplusExt = 807 CGdiplusExt& GdiplusExt =
808 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 808 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
809 CallFunc(GdipSetTextRenderingHint)((GpGraphics*)graphics, 809 CallFunc(GdipSetTextRenderingHint)((GpGraphics*)graphics,
810 (TextRenderingHint)mode); 810 (TextRenderingHint)mode);
811 } 811 }
812 void CGdiplusExt::GdipSetPageUnit(void* graphics, uint32_t unit) { 812 void CGdiplusExt::GdipSetPageUnit(void* graphics, uint32_t unit) {
813 CGdiplusExt& GdiplusExt = 813 CGdiplusExt& GdiplusExt =
814 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 814 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
815 CallFunc(GdipSetPageUnit)((GpGraphics*)graphics, (GpUnit)unit); 815 CallFunc(GdipSetPageUnit)((GpGraphics*)graphics, (GpUnit)unit);
816 } 816 }
817 FX_BOOL CGdiplusExt::GdipDrawDriverString(void* graphics, 817 bool CGdiplusExt::GdipDrawDriverString(void* graphics,
818 unsigned short* text, 818 unsigned short* text,
819 int length, 819 int length,
820 void* font, 820 void* font,
821 void* brush, 821 void* brush,
822 void* positions, 822 void* positions,
823 int flags, 823 int flags,
824 const void* matrix) { 824 const void* matrix) {
825 CGdiplusExt& GdiplusExt = 825 CGdiplusExt& GdiplusExt =
826 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 826 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
827 GpStatus status = CallFunc(GdipDrawDriverString)( 827 GpStatus status = CallFunc(GdipDrawDriverString)(
828 (GpGraphics*)graphics, (GDIPCONST UINT16*)text, (INT)length, 828 (GpGraphics*)graphics, (GDIPCONST UINT16*)text, (INT)length,
829 (GDIPCONST GpFont*)font, (GDIPCONST GpBrush*)brush, 829 (GDIPCONST GpFont*)font, (GDIPCONST GpBrush*)brush,
830 (GDIPCONST PointF*)positions, (INT)flags, (GDIPCONST GpMatrix*)matrix); 830 (GDIPCONST PointF*)positions, (INT)flags, (GDIPCONST GpMatrix*)matrix);
831 if (status == Ok) { 831 if (status == Ok) {
832 return TRUE; 832 return true;
833 } 833 }
834 return FALSE; 834 return false;
835 } 835 }
836 void CGdiplusExt::GdipCreateBrush(uint32_t fill_argb, void** pBrush) { 836 void CGdiplusExt::GdipCreateBrush(uint32_t fill_argb, void** pBrush) {
837 CGdiplusExt& GdiplusExt = 837 CGdiplusExt& GdiplusExt =
838 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 838 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
839 CallFunc(GdipCreateSolidFill)((ARGB)fill_argb, (GpSolidFill**)pBrush); 839 CallFunc(GdipCreateSolidFill)((ARGB)fill_argb, (GpSolidFill**)pBrush);
840 } 840 }
841 void CGdiplusExt::GdipDeleteBrush(void* pBrush) { 841 void CGdiplusExt::GdipDeleteBrush(void* pBrush) {
842 CGdiplusExt& GdiplusExt = 842 CGdiplusExt& GdiplusExt =
843 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 843 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
844 CallFunc(GdipDeleteBrush)((GpSolidFill*)pBrush); 844 CallFunc(GdipDeleteBrush)((GpSolidFill*)pBrush);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 void CGdiplusExt::GdipDisposeImage(void* bitmap) { 902 void CGdiplusExt::GdipDisposeImage(void* bitmap) {
903 CGdiplusExt& GdiplusExt = 903 CGdiplusExt& GdiplusExt =
904 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 904 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
905 CallFunc(GdipDisposeImage)((GpBitmap*)bitmap); 905 CallFunc(GdipDisposeImage)((GpBitmap*)bitmap);
906 } 906 }
907 void CGdiplusExt::GdipDeleteGraphics(void* graphics) { 907 void CGdiplusExt::GdipDeleteGraphics(void* graphics) {
908 CGdiplusExt& GdiplusExt = 908 CGdiplusExt& GdiplusExt =
909 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 909 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
910 CallFunc(GdipDeleteGraphics)((GpGraphics*)graphics); 910 CallFunc(GdipDeleteGraphics)((GpGraphics*)graphics);
911 } 911 }
912 FX_BOOL CGdiplusExt::StretchBitMask(HDC hDC, 912 bool CGdiplusExt::StretchBitMask(HDC hDC,
913 BOOL bMonoDevice, 913 BOOL bMonoDevice,
914 const CFX_DIBitmap* pBitmap, 914 const CFX_DIBitmap* pBitmap,
915 int dest_left, 915 int dest_left,
916 int dest_top, 916 int dest_top,
917 int dest_width, 917 int dest_width,
918 int dest_height, 918 int dest_height,
919 uint32_t argb, 919 uint32_t argb,
920 const FX_RECT* pClipRect, 920 const FX_RECT* pClipRect,
921 int flags) { 921 int flags) {
922 ASSERT(pBitmap->GetBPP() == 1); 922 ASSERT(pBitmap->GetBPP() == 1);
923 CGdiplusExt& GdiplusExt = 923 CGdiplusExt& GdiplusExt =
924 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 924 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
925 GpGraphics* pGraphics = nullptr; 925 GpGraphics* pGraphics = nullptr;
926 CallFunc(GdipCreateFromHDC)(hDC, &pGraphics); 926 CallFunc(GdipCreateFromHDC)(hDC, &pGraphics);
927 CallFunc(GdipSetPageUnit)(pGraphics, UnitPixel); 927 CallFunc(GdipSetPageUnit)(pGraphics, UnitPixel);
928 if (flags & FXDIB_NOSMOOTH) { 928 if (flags & FXDIB_NOSMOOTH) {
929 CallFunc(GdipSetInterpolationMode)(pGraphics, 929 CallFunc(GdipSetInterpolationMode)(pGraphics,
930 InterpolationModeNearestNeighbor); 930 InterpolationModeNearestNeighbor);
931 } else { 931 } else {
932 CallFunc(GdipSetInterpolationMode)(pGraphics, InterpolationModeHighQuality); 932 CallFunc(GdipSetInterpolationMode)(pGraphics, InterpolationModeHighQuality);
933 } 933 }
934 OutputImageMask(pGraphics, bMonoDevice, pBitmap, dest_left, dest_top, 934 OutputImageMask(pGraphics, bMonoDevice, pBitmap, dest_left, dest_top,
935 dest_width, dest_height, argb, pClipRect); 935 dest_width, dest_height, argb, pClipRect);
936 CallFunc(GdipDeleteGraphics)(pGraphics); 936 CallFunc(GdipDeleteGraphics)(pGraphics);
937 return TRUE; 937 return true;
938 } 938 }
939 FX_BOOL CGdiplusExt::StretchDIBits(HDC hDC, 939 bool CGdiplusExt::StretchDIBits(HDC hDC,
940 const CFX_DIBitmap* pBitmap, 940 const CFX_DIBitmap* pBitmap,
941 int dest_left, 941 int dest_left,
942 int dest_top, 942 int dest_top,
943 int dest_width, 943 int dest_width,
944 int dest_height, 944 int dest_height,
945 const FX_RECT* pClipRect, 945 const FX_RECT* pClipRect,
946 int flags) { 946 int flags) {
947 GpGraphics* pGraphics; 947 GpGraphics* pGraphics;
948 CGdiplusExt& GdiplusExt = 948 CGdiplusExt& GdiplusExt =
949 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 949 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
950 CallFunc(GdipCreateFromHDC)(hDC, &pGraphics); 950 CallFunc(GdipCreateFromHDC)(hDC, &pGraphics);
951 CallFunc(GdipSetPageUnit)(pGraphics, UnitPixel); 951 CallFunc(GdipSetPageUnit)(pGraphics, UnitPixel);
952 if (flags & FXDIB_NOSMOOTH) { 952 if (flags & FXDIB_NOSMOOTH) {
953 CallFunc(GdipSetInterpolationMode)(pGraphics, 953 CallFunc(GdipSetInterpolationMode)(pGraphics,
954 InterpolationModeNearestNeighbor); 954 InterpolationModeNearestNeighbor);
955 } else if (pBitmap->GetWidth() > abs(dest_width) / 2 || 955 } else if (pBitmap->GetWidth() > abs(dest_width) / 2 ||
956 pBitmap->GetHeight() > abs(dest_height) / 2) { 956 pBitmap->GetHeight() > abs(dest_height) / 2) {
957 CallFunc(GdipSetInterpolationMode)(pGraphics, InterpolationModeHighQuality); 957 CallFunc(GdipSetInterpolationMode)(pGraphics, InterpolationModeHighQuality);
958 } else { 958 } else {
959 CallFunc(GdipSetInterpolationMode)(pGraphics, InterpolationModeBilinear); 959 CallFunc(GdipSetInterpolationMode)(pGraphics, InterpolationModeBilinear);
960 } 960 }
961 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); 961 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
962 OutputImage(pGraphics, pBitmap, &src_rect, dest_left, dest_top, dest_width, 962 OutputImage(pGraphics, pBitmap, &src_rect, dest_left, dest_top, dest_width,
963 dest_height); 963 dest_height);
964 CallFunc(GdipDeleteGraphics)(pGraphics); 964 CallFunc(GdipDeleteGraphics)(pGraphics);
965 CallFunc(GdipDeleteGraphics)(pGraphics); 965 CallFunc(GdipDeleteGraphics)(pGraphics);
966 return TRUE; 966 return true;
967 } 967 }
968 static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, 968 static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState,
969 const CFX_Matrix* pMatrix, 969 const CFX_Matrix* pMatrix,
970 DWORD argb, 970 DWORD argb,
971 FX_BOOL bTextMode = FALSE) { 971 bool bTextMode = false) {
972 CGdiplusExt& GdiplusExt = 972 CGdiplusExt& GdiplusExt =
973 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 973 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
974 FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f; 974 FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f;
975 if (!bTextMode) { 975 if (!bTextMode) {
976 FX_FLOAT unit = 976 FX_FLOAT unit =
977 pMatrix ? 1.0f / ((pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2) 977 pMatrix ? 1.0f / ((pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2)
978 : 1.0f; 978 : 1.0f;
979 if (width < unit) { 979 if (width < unit) {
980 width = unit; 980 width = unit;
981 } 981 }
982 } 982 }
983 GpPen* pPen = nullptr; 983 GpPen* pPen = nullptr;
984 CallFunc(GdipCreatePen1)((ARGB)argb, width, UnitWorld, &pPen); 984 CallFunc(GdipCreatePen1)((ARGB)argb, width, UnitWorld, &pPen);
985 LineCap lineCap = LineCapFlat; 985 LineCap lineCap = LineCapFlat;
986 DashCap dashCap = DashCapFlat; 986 DashCap dashCap = DashCapFlat;
987 FX_BOOL bDashExtend = FALSE; 987 bool bDashExtend = false;
988 switch (pGraphState->m_LineCap) { 988 switch (pGraphState->m_LineCap) {
989 case CFX_GraphStateData::LineCapButt: 989 case CFX_GraphStateData::LineCapButt:
990 lineCap = LineCapFlat; 990 lineCap = LineCapFlat;
991 break; 991 break;
992 case CFX_GraphStateData::LineCapRound: 992 case CFX_GraphStateData::LineCapRound:
993 lineCap = LineCapRound; 993 lineCap = LineCapRound;
994 dashCap = DashCapRound; 994 dashCap = DashCapRound;
995 bDashExtend = TRUE; 995 bDashExtend = true;
996 break; 996 break;
997 case CFX_GraphStateData::LineCapSquare: 997 case CFX_GraphStateData::LineCapSquare:
998 lineCap = LineCapSquare; 998 lineCap = LineCapSquare;
999 bDashExtend = TRUE; 999 bDashExtend = true;
1000 break; 1000 break;
1001 } 1001 }
1002 CallFunc(GdipSetPenLineCap197819)(pPen, lineCap, lineCap, dashCap); 1002 CallFunc(GdipSetPenLineCap197819)(pPen, lineCap, lineCap, dashCap);
1003 LineJoin lineJoin = LineJoinMiterClipped; 1003 LineJoin lineJoin = LineJoinMiterClipped;
1004 switch (pGraphState->m_LineJoin) { 1004 switch (pGraphState->m_LineJoin) {
1005 case CFX_GraphStateData::LineJoinMiter: 1005 case CFX_GraphStateData::LineJoinMiter:
1006 lineJoin = LineJoinMiterClipped; 1006 lineJoin = LineJoinMiterClipped;
1007 break; 1007 break;
1008 case CFX_GraphStateData::LineJoinRound: 1008 case CFX_GraphStateData::LineJoinRound:
1009 lineJoin = LineJoinRound; 1009 lineJoin = LineJoinRound;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 phase -= 0.5f; 1064 phase -= 0.5f;
1065 } 1065 }
1066 } 1066 }
1067 CallFunc(GdipSetPenDashOffset)(pPen, phase); 1067 CallFunc(GdipSetPenDashOffset)(pPen, phase);
1068 FX_Free(pDashArray); 1068 FX_Free(pDashArray);
1069 pDashArray = nullptr; 1069 pDashArray = nullptr;
1070 } 1070 }
1071 CallFunc(GdipSetPenMiterLimit)(pPen, pGraphState->m_MiterLimit); 1071 CallFunc(GdipSetPenMiterLimit)(pPen, pGraphState->m_MiterLimit);
1072 return pPen; 1072 return pPen;
1073 } 1073 }
1074 static FX_BOOL IsSmallTriangle(PointF* points, 1074 static bool IsSmallTriangle(PointF* points,
1075 const CFX_Matrix* pMatrix, 1075 const CFX_Matrix* pMatrix,
1076 int& v1, 1076 int& v1,
1077 int& v2) { 1077 int& v2) {
1078 int pairs[] = {1, 2, 0, 2, 0, 1}; 1078 int pairs[] = {1, 2, 0, 2, 0, 1};
1079 for (int i = 0; i < 3; i++) { 1079 for (int i = 0; i < 3; i++) {
1080 int pair1 = pairs[i * 2]; 1080 int pair1 = pairs[i * 2];
1081 int pair2 = pairs[i * 2 + 1]; 1081 int pair2 = pairs[i * 2 + 1];
1082 FX_FLOAT x1 = points[pair1].X, x2 = points[pair2].X; 1082 FX_FLOAT x1 = points[pair1].X, x2 = points[pair2].X;
1083 FX_FLOAT y1 = points[pair1].Y, y2 = points[pair2].Y; 1083 FX_FLOAT y1 = points[pair1].Y, y2 = points[pair2].Y;
1084 if (pMatrix) { 1084 if (pMatrix) {
1085 pMatrix->Transform(x1, y1); 1085 pMatrix->Transform(x1, y1);
1086 pMatrix->Transform(x2, y2); 1086 pMatrix->Transform(x2, y2);
1087 } 1087 }
1088 FX_FLOAT dx = x1 - x2; 1088 FX_FLOAT dx = x1 - x2;
1089 FX_FLOAT dy = y1 - y2; 1089 FX_FLOAT dy = y1 - y2;
1090 FX_FLOAT distance_square = (dx * dx) + (dy * dy); 1090 FX_FLOAT distance_square = (dx * dx) + (dy * dy);
1091 if (distance_square < (1.0f * 2 + 1.0f / 4)) { 1091 if (distance_square < (1.0f * 2 + 1.0f / 4)) {
1092 v1 = i; 1092 v1 = i;
1093 v2 = pair1; 1093 v2 = pair1;
1094 return TRUE; 1094 return true;
1095 } 1095 }
1096 } 1096 }
1097 return FALSE; 1097 return false;
1098 } 1098 }
1099 FX_BOOL CGdiplusExt::DrawPath(HDC hDC, 1099 bool CGdiplusExt::DrawPath(HDC hDC,
1100 const CFX_PathData* pPathData, 1100 const CFX_PathData* pPathData,
1101 const CFX_Matrix* pObject2Device, 1101 const CFX_Matrix* pObject2Device,
1102 const CFX_GraphStateData* pGraphState, 1102 const CFX_GraphStateData* pGraphState,
1103 uint32_t fill_argb, 1103 uint32_t fill_argb,
1104 uint32_t stroke_argb, 1104 uint32_t stroke_argb,
1105 int fill_mode) { 1105 int fill_mode) {
1106 int nPoints = pPathData->GetPointCount(); 1106 int nPoints = pPathData->GetPointCount();
1107 if (nPoints == 0) { 1107 if (nPoints == 0) {
1108 return TRUE; 1108 return true;
1109 } 1109 }
1110 FX_PATHPOINT* pPoints = pPathData->GetPoints(); 1110 FX_PATHPOINT* pPoints = pPathData->GetPoints();
1111 GpGraphics* pGraphics = nullptr; 1111 GpGraphics* pGraphics = nullptr;
1112 CGdiplusExt& GdiplusExt = 1112 CGdiplusExt& GdiplusExt =
1113 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 1113 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
1114 CallFunc(GdipCreateFromHDC)(hDC, &pGraphics); 1114 CallFunc(GdipCreateFromHDC)(hDC, &pGraphics);
1115 CallFunc(GdipSetPageUnit)(pGraphics, UnitPixel); 1115 CallFunc(GdipSetPageUnit)(pGraphics, UnitPixel);
1116 CallFunc(GdipSetPixelOffsetMode)(pGraphics, PixelOffsetModeHalf); 1116 CallFunc(GdipSetPixelOffsetMode)(pGraphics, PixelOffsetModeHalf);
1117 GpMatrix* pMatrix = nullptr; 1117 GpMatrix* pMatrix = nullptr;
1118 if (pObject2Device) { 1118 if (pObject2Device) {
1119 CallFunc(GdipCreateMatrix2)(pObject2Device->a, pObject2Device->b, 1119 CallFunc(GdipCreateMatrix2)(pObject2Device->a, pObject2Device->b,
1120 pObject2Device->c, pObject2Device->d, 1120 pObject2Device->c, pObject2Device->d,
1121 pObject2Device->e, pObject2Device->f, &pMatrix); 1121 pObject2Device->e, pObject2Device->f, &pMatrix);
1122 CallFunc(GdipSetWorldTransform)(pGraphics, pMatrix); 1122 CallFunc(GdipSetWorldTransform)(pGraphics, pMatrix);
1123 } 1123 }
1124 PointF* points = FX_Alloc(PointF, nPoints); 1124 PointF* points = FX_Alloc(PointF, nPoints);
1125 BYTE* types = FX_Alloc(BYTE, nPoints); 1125 BYTE* types = FX_Alloc(BYTE, nPoints);
1126 int nSubPathes = 0; 1126 int nSubPathes = 0;
1127 FX_BOOL bSubClose = FALSE; 1127 bool bSubClose = false;
1128 int pos_subclose = 0; 1128 int pos_subclose = 0;
1129 FX_BOOL bSmooth = FALSE; 1129 bool bSmooth = false;
1130 int startpoint = 0; 1130 int startpoint = 0;
1131 for (int i = 0; i < nPoints; i++) { 1131 for (int i = 0; i < nPoints; i++) {
1132 points[i].X = pPoints[i].m_PointX; 1132 points[i].X = pPoints[i].m_PointX;
1133 points[i].Y = pPoints[i].m_PointY; 1133 points[i].Y = pPoints[i].m_PointY;
1134 FX_FLOAT x, y; 1134 FX_FLOAT x, y;
1135 if (pObject2Device) { 1135 if (pObject2Device) {
1136 pObject2Device->Transform(pPoints[i].m_PointX, pPoints[i].m_PointY, x, y); 1136 pObject2Device->Transform(pPoints[i].m_PointX, pPoints[i].m_PointY, x, y);
1137 } else { 1137 } else {
1138 x = pPoints[i].m_PointX; 1138 x = pPoints[i].m_PointX;
1139 y = pPoints[i].m_PointY; 1139 y = pPoints[i].m_PointY;
1140 } 1140 }
1141 if (x > 50000 * 1.0f) { 1141 if (x > 50000 * 1.0f) {
1142 points[i].X = 50000 * 1.0f; 1142 points[i].X = 50000 * 1.0f;
1143 } 1143 }
1144 if (x < -50000 * 1.0f) { 1144 if (x < -50000 * 1.0f) {
1145 points[i].X = -50000 * 1.0f; 1145 points[i].X = -50000 * 1.0f;
1146 } 1146 }
1147 if (y > 50000 * 1.0f) { 1147 if (y > 50000 * 1.0f) {
1148 points[i].Y = 50000 * 1.0f; 1148 points[i].Y = 50000 * 1.0f;
1149 } 1149 }
1150 if (y < -50000 * 1.0f) { 1150 if (y < -50000 * 1.0f) {
1151 points[i].Y = -50000 * 1.0f; 1151 points[i].Y = -50000 * 1.0f;
1152 } 1152 }
1153 int point_type = pPoints[i].m_Flag & FXPT_TYPE; 1153 int point_type = pPoints[i].m_Flag & FXPT_TYPE;
1154 if (point_type == FXPT_MOVETO) { 1154 if (point_type == FXPT_MOVETO) {
1155 types[i] = PathPointTypeStart; 1155 types[i] = PathPointTypeStart;
1156 nSubPathes++; 1156 nSubPathes++;
1157 bSubClose = FALSE; 1157 bSubClose = false;
1158 startpoint = i; 1158 startpoint = i;
1159 } else if (point_type == FXPT_LINETO) { 1159 } else if (point_type == FXPT_LINETO) {
1160 types[i] = PathPointTypeLine; 1160 types[i] = PathPointTypeLine;
1161 if (pPoints[i - 1].m_Flag == FXPT_MOVETO && 1161 if (pPoints[i - 1].m_Flag == FXPT_MOVETO &&
1162 (i == nPoints - 1 || pPoints[i + 1].m_Flag == FXPT_MOVETO) && 1162 (i == nPoints - 1 || pPoints[i + 1].m_Flag == FXPT_MOVETO) &&
1163 points[i].Y == points[i - 1].Y && points[i].X == points[i - 1].X) { 1163 points[i].Y == points[i - 1].Y && points[i].X == points[i - 1].X) {
1164 points[i].X += 0.01f; 1164 points[i].X += 0.01f;
1165 continue; 1165 continue;
1166 } 1166 }
1167 if (!bSmooth && points[i].X != points[i - 1].X && 1167 if (!bSmooth && points[i].X != points[i - 1].X &&
1168 points[i].Y != points[i - 1].Y) { 1168 points[i].Y != points[i - 1].Y) {
1169 bSmooth = TRUE; 1169 bSmooth = true;
1170 } 1170 }
1171 } else if (point_type == FXPT_BEZIERTO) { 1171 } else if (point_type == FXPT_BEZIERTO) {
1172 types[i] = PathPointTypeBezier; 1172 types[i] = PathPointTypeBezier;
1173 bSmooth = TRUE; 1173 bSmooth = true;
1174 } 1174 }
1175 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) { 1175 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) {
1176 if (bSubClose) { 1176 if (bSubClose) {
1177 types[pos_subclose] &= ~PathPointTypeCloseSubpath; 1177 types[pos_subclose] &= ~PathPointTypeCloseSubpath;
1178 } else { 1178 } else {
1179 bSubClose = TRUE; 1179 bSubClose = true;
1180 } 1180 }
1181 pos_subclose = i; 1181 pos_subclose = i;
1182 types[i] |= PathPointTypeCloseSubpath; 1182 types[i] |= PathPointTypeCloseSubpath;
1183 if (!bSmooth && points[i].X != points[startpoint].X && 1183 if (!bSmooth && points[i].X != points[startpoint].X &&
1184 points[i].Y != points[startpoint].Y) { 1184 points[i].Y != points[startpoint].Y) {
1185 bSmooth = TRUE; 1185 bSmooth = true;
1186 } 1186 }
1187 } 1187 }
1188 } 1188 }
1189 if (fill_mode & FXFILL_NOPATHSMOOTH) { 1189 if (fill_mode & FXFILL_NOPATHSMOOTH) {
1190 bSmooth = FALSE; 1190 bSmooth = false;
1191 CallFunc(GdipSetSmoothingMode)(pGraphics, SmoothingModeNone); 1191 CallFunc(GdipSetSmoothingMode)(pGraphics, SmoothingModeNone);
1192 } else if (!(fill_mode & FXFILL_FULLCOVER)) { 1192 } else if (!(fill_mode & FXFILL_FULLCOVER)) {
1193 if (!bSmooth && (fill_mode & 3)) { 1193 if (!bSmooth && (fill_mode & 3)) {
1194 bSmooth = TRUE; 1194 bSmooth = true;
1195 } 1195 }
1196 if (bSmooth || (pGraphState && pGraphState->m_LineWidth > 2)) { 1196 if (bSmooth || (pGraphState && pGraphState->m_LineWidth > 2)) {
1197 CallFunc(GdipSetSmoothingMode)(pGraphics, SmoothingModeAntiAlias); 1197 CallFunc(GdipSetSmoothingMode)(pGraphics, SmoothingModeAntiAlias);
1198 } 1198 }
1199 } 1199 }
1200 int new_fill_mode = fill_mode & 3; 1200 int new_fill_mode = fill_mode & 3;
1201 if (nPoints == 4 && !pGraphState) { 1201 if (nPoints == 4 && !pGraphState) {
1202 int v1, v2; 1202 int v1, v2;
1203 if (IsSmallTriangle(points, pObject2Device, v1, v2)) { 1203 if (IsSmallTriangle(points, pObject2Device, v1, v2)) {
1204 GpPen* pPen = nullptr; 1204 GpPen* pPen = nullptr;
1205 CallFunc(GdipCreatePen1)(fill_argb, 1.0f, UnitPixel, &pPen); 1205 CallFunc(GdipCreatePen1)(fill_argb, 1.0f, UnitPixel, &pPen);
1206 CallFunc(GdipDrawLineI)( 1206 CallFunc(GdipDrawLineI)(
1207 pGraphics, pPen, FXSYS_round(points[v1].X), FXSYS_round(points[v1].Y), 1207 pGraphics, pPen, FXSYS_round(points[v1].X), FXSYS_round(points[v1].Y),
1208 FXSYS_round(points[v2].X), FXSYS_round(points[v2].Y)); 1208 FXSYS_round(points[v2].X), FXSYS_round(points[v2].Y));
1209 CallFunc(GdipDeletePen)(pPen); 1209 CallFunc(GdipDeletePen)(pPen);
1210 return TRUE; 1210 return true;
1211 } 1211 }
1212 } 1212 }
1213 GpPath* pGpPath = nullptr; 1213 GpPath* pGpPath = nullptr;
1214 CallFunc(GdipCreatePath2)(points, types, nPoints, 1214 CallFunc(GdipCreatePath2)(points, types, nPoints,
1215 GdiFillType2Gdip(new_fill_mode), &pGpPath); 1215 GdiFillType2Gdip(new_fill_mode), &pGpPath);
1216 if (!pGpPath) { 1216 if (!pGpPath) {
1217 if (pMatrix) { 1217 if (pMatrix) {
1218 CallFunc(GdipDeleteMatrix)(pMatrix); 1218 CallFunc(GdipDeleteMatrix)(pMatrix);
1219 } 1219 }
1220 FX_Free(points); 1220 FX_Free(points);
1221 FX_Free(types); 1221 FX_Free(types);
1222 CallFunc(GdipDeleteGraphics)(pGraphics); 1222 CallFunc(GdipDeleteGraphics)(pGraphics);
1223 return FALSE; 1223 return false;
1224 } 1224 }
1225 if (new_fill_mode) { 1225 if (new_fill_mode) {
1226 GpBrush* pBrush = _GdipCreateBrush(fill_argb); 1226 GpBrush* pBrush = _GdipCreateBrush(fill_argb);
1227 CallFunc(GdipSetPathFillMode)(pGpPath, GdiFillType2Gdip(new_fill_mode)); 1227 CallFunc(GdipSetPathFillMode)(pGpPath, GdiFillType2Gdip(new_fill_mode));
1228 CallFunc(GdipFillPath)(pGraphics, pBrush, pGpPath); 1228 CallFunc(GdipFillPath)(pGraphics, pBrush, pGpPath);
1229 CallFunc(GdipDeleteBrush)(pBrush); 1229 CallFunc(GdipDeleteBrush)(pBrush);
1230 } 1230 }
1231 if (pGraphState && stroke_argb) { 1231 if (pGraphState && stroke_argb) {
1232 GpPen* pPen = _GdipCreatePen(pGraphState, pObject2Device, stroke_argb, 1232 GpPen* pPen = _GdipCreatePen(pGraphState, pObject2Device, stroke_argb,
1233 !!(fill_mode & FX_STROKE_TEXT_MODE)); 1233 !!(fill_mode & FX_STROKE_TEXT_MODE));
(...skipping 15 matching lines...) Expand all
1249 } 1249 }
1250 CallFunc(GdipDeletePen)(pPen); 1250 CallFunc(GdipDeletePen)(pPen);
1251 } 1251 }
1252 if (pMatrix) { 1252 if (pMatrix) {
1253 CallFunc(GdipDeleteMatrix)(pMatrix); 1253 CallFunc(GdipDeleteMatrix)(pMatrix);
1254 } 1254 }
1255 FX_Free(points); 1255 FX_Free(points);
1256 FX_Free(types); 1256 FX_Free(types);
1257 CallFunc(GdipDeletePath)(pGpPath); 1257 CallFunc(GdipDeletePath)(pGpPath);
1258 CallFunc(GdipDeleteGraphics)(pGraphics); 1258 CallFunc(GdipDeleteGraphics)(pGraphics);
1259 return TRUE; 1259 return true;
1260 } 1260 }
1261 1261
1262 class GpStream final : public IStream { 1262 class GpStream final : public IStream {
1263 public: 1263 public:
1264 GpStream() : m_RefCount(1), m_ReadPos(0) {} 1264 GpStream() : m_RefCount(1), m_ReadPos(0) {}
1265 1265
1266 // IUnknown 1266 // IUnknown
1267 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, 1267 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
1268 void** ppvObject) override { 1268 void** ppvObject) override {
1269 if (iid == __uuidof(IUnknown) || iid == __uuidof(IStream) || 1269 if (iid == __uuidof(IUnknown) || iid == __uuidof(IStream) ||
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 FX_Free(pInfo->pBitmapData); 1490 FX_Free(pInfo->pBitmapData);
1491 FX_Free((LPBYTE)pInfo->pbmi); 1491 FX_Free((LPBYTE)pInfo->pbmi);
1492 if (pInfo->pStream) { 1492 if (pInfo->pStream) {
1493 pInfo->pStream->Release(); 1493 pInfo->pStream->Release();
1494 } 1494 }
1495 FX_Free(pInfo); 1495 FX_Free(pInfo);
1496 } 1496 }
1497 1497
1498 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi, 1498 CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi,
1499 LPVOID pData, 1499 LPVOID pData,
1500 FX_BOOL bAlpha); 1500 bool bAlpha);
1501 CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) { 1501 CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) {
1502 PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args); 1502 PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args);
1503 if (!pInfo) { 1503 if (!pInfo) {
1504 return nullptr; 1504 return nullptr;
1505 } 1505 }
1506 int height = abs(pInfo->pbmi->bmiHeader.biHeight); 1506 int height = abs(pInfo->pbmi->bmiHeader.biHeight);
1507 int width = pInfo->pbmi->bmiHeader.biWidth; 1507 int width = pInfo->pbmi->bmiHeader.biWidth;
1508 int dest_pitch = (width * pInfo->pbmi->bmiHeader.biBitCount + 31) / 32 * 4; 1508 int dest_pitch = (width * pInfo->pbmi->bmiHeader.biBitCount + 31) / 32 * 4;
1509 LPBYTE pData = FX_Alloc2D(BYTE, dest_pitch, height); 1509 LPBYTE pData = FX_Alloc2D(BYTE, dest_pitch, height);
1510 if (dest_pitch == pInfo->Stride) { 1510 if (dest_pitch == pInfo->Stride) {
1511 FXSYS_memcpy(pData, pInfo->pScan0, dest_pitch * height); 1511 FXSYS_memcpy(pData, pInfo->pScan0, dest_pitch * height);
1512 } else { 1512 } else {
1513 for (int i = 0; i < height; i++) { 1513 for (int i = 0; i < height; i++) {
1514 FXSYS_memcpy(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, 1514 FXSYS_memcpy(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i,
1515 dest_pitch); 1515 dest_pitch);
1516 } 1516 }
1517 } 1517 }
1518 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf( 1518 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf(
1519 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); 1519 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32);
1520 FX_Free(pData); 1520 FX_Free(pData);
1521 FreeDIBitmap(pInfo); 1521 FreeDIBitmap(pInfo);
1522 return pDIBitmap; 1522 return pDIBitmap;
1523 } 1523 }
OLDNEW
« no previous file with comments | « core/fxge/win32/fx_win32_dwrite.cpp ('k') | core/fxge/win32/fx_win32_print.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698