00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #include "camtypes.h"
00101
00102 #ifndef EXCLUDE_GALS
00103 #include "bfxalu.h"
00104 #include "textfuns.h"
00105
00106
00107 #include "bitmpinf.h"
00108
00109 #include "grndrgn.h"
00110 #include "wbitmap.h"
00111
00112
00113
00114 #include "fontpgen.h"
00115 #include "progress.h"
00116
00117 #include "dlgcol.h"
00118 #include "unicdman.h"
00119
00120
00121
00122
00123 CC_IMPLEMENT_DYNAMIC(StringToBitmap, BitmapEffectBase)
00124
00125
00126 #define new CAM_DEBUG_NEW
00127
00128
00129
00130
00131 const INT32 S2BMP_BACKGROUND_COLOUR = 0x00ffffff;
00132 const INT32 S2BMP_FOREGROUND_COLOUR = 0x00000000;
00133
00134
00135 const BOOL S2BMP_ANTIALIAS = TRUE;
00136
00137
00138 const INT32 S2BMP_MAGIC = 2000;
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 StringToBitmap::StringToBitmap(void)
00153 {
00154 }
00155
00156
00157
00158 StringToBitmap::~StringToBitmap(void)
00159 {
00160 }
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 BOOL StringToBitmap::SaveBitmap(KernelBitmap *Bitmap, PathName *Path)
00177 {
00178 BOOL ok = TRUE;
00179
00180
00181
00182
00183
00184
00185
00186
00187 CCDiskFile OutputFile;
00188 PathName TmpPath(*Path);
00189 ok = OutputFile.open(TmpPath, ios::out | ios::binary);
00190 if(!ok) ERROR3("s2bmp OutputFile.open returned false");
00191 if(!ok) return FALSE;
00192
00193
00194
00195 const UINT32 OutputDepth = Bitmap->GetBPP();
00196
00197 if(OutputDepth != 8 && OutputDepth != 32)
00198 {
00199 ERROR3("Wrong bpp for saving bmp in fontpgen");
00200 return FALSE;
00201 }
00202
00203
00204 BitmapInfo Info;
00205 BitmapInfo *lpInfo = &Info;
00206 ok = Bitmap->ActualBitmap->GetInfo(lpInfo);
00207 if(!ok) ERROR3("s2bmp Bitmap->ActualBitmap->GetInfo(lpInfo) returned false");
00208 if(!ok) return FALSE;
00209
00210 LPBITMAPINFOHEADER pBMI =&(((WinBitmap *)(Bitmap->ActualBitmap))->BMInfo->bmiHeader);
00211 ok = (pBMI!=NULL);
00212 if(!ok) ERROR3("s2bmp pBMI!=NULL returned false");
00213 if(!ok) return FALSE;
00214
00215 UINT32 Ysize = pBMI->biHeight;
00216
00217
00218 LPLOGPALETTE lpPalette = NULL;
00219
00220 DWORD space[258];
00221 if(OutputDepth<=8)
00222 {
00223
00224 lpPalette = (LPLOGPALETTE)(void *)(space);
00225 memcpy(lpPalette->palPalEntry , (pBMI+1), (pBMI->biClrUsed)*sizeof(DWORD));
00226 lpPalette->palVersion = 0x300;
00227 lpPalette->palNumEntries = (unsigned short)(pBMI->biClrUsed);
00228 }
00229
00230
00231 UINT32 Compress = BI_RGB;
00232
00233
00234
00235
00236 OutputDIB DestDIB;
00237
00238 BeginSlowJob(100, TRUE, &(String_64)"Creating thumbnail");
00239
00240 ok = DestDIB.StartFile( &OutputFile, pBMI, lpPalette,
00241 OutputDepth,
00242 Compress,
00243 (UINT32) Ysize,
00244 100);
00245
00246 if(!ok) ERROR3("DestDIB.StartFile returned false");
00247 if(!ok) EndSlowJob();
00248 if(!ok) return FALSE;
00249
00250
00251 ok = DestDIB.WriteBlock(0, Ysize, ((WinBitmap *)(Bitmap->ActualBitmap))->BMBytes, (UINT32) Bitmap->GetBPP());
00252 if(!ok) ERROR3("DestDIB.WriteBlock returned false");
00253 if(!ok) EndSlowJob();
00254 if(!ok) return FALSE;
00255
00256
00257 ok = DestDIB.TidyUp();
00258
00259 EndSlowJob();
00260
00261 if(!ok) ERROR3("DestDIB.TidyUp returned false");
00262 if(!ok) return FALSE;
00263
00264 return TRUE;
00265 }
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286 BOOL StringToBitmap::BlankBitmap(UINT32 Xsize, UINT32 Ysize, UINT32 BPP, UINT32 BackCol,
00287 KernelBitmap **BM)
00288 {
00289
00290 BOOL ok = TRUE;
00291
00292
00293 INT32 Width = Xsize;
00294 INT32 Height = Ysize;
00295 INT32 Depth = BPP;
00296 INT32 DPI = 96;
00297 KernelBitmap * Bitmap = new KernelBitmap(Width,Height,Depth,DPI, TRUE);
00298 Error::ClearError();
00299
00300
00301 ok = ( (Bitmap != NULL) && (Bitmap->ActualBitmap != NULL)
00302 && (((WinBitmap *)(Bitmap->ActualBitmap))->BMInfo != NULL)
00303 && (((WinBitmap *)(Bitmap->ActualBitmap))->BMBytes != NULL) );
00304
00305 ERROR3IF(!ok, "BlankBitmap can't allocate space for bitmap");
00306 if(ok)
00307 {
00308
00309 if(BPP <= 8)
00310 {
00311
00312 DWORD Entries = ((WinBitmap*)Bitmap->ActualBitmap)->BMInfo->bmiHeader.biClrUsed;
00313 if (Entries==0) Entries = 1<<BPP;
00314 RGBQUAD Quad;
00315 INT32 i;
00316 BYTE Value;
00317
00318
00319 INT32 Mult = 256 / Entries;
00320
00321 ((WinBitmap*)Bitmap->ActualBitmap)->BMInfo->bmiHeader.biClrImportant = Entries;
00322
00323 for(i=0; i < (INT32)Entries; i++)
00324 {
00325 Value = i * Mult;
00326
00327 if(Value > 255) Value = 255;
00328
00329
00330 Quad.rgbBlue = Value;
00331 Quad.rgbGreen = Value;
00332 Quad.rgbRed = Value;
00333 Quad.rgbReserved = 0;
00334
00335
00336 ((WinBitmap*)Bitmap->ActualBitmap)->BMInfo->bmiColors[i] = Quad;
00337
00338 }
00339 }
00340
00341
00342 ok = ALU->SetA(Bitmap);
00343 ERROR3IF(!ok, "BlankBitmap ALU->SetA returned false");
00344 if(ok)
00345 {
00346
00347 ok = ALU->ZeroA(BackCol);
00348 ERROR3IF(!ok, "BlankBitmap ALU->ZeroA returned false");
00349 }
00350 }
00351
00352 if(!ok && Bitmap != NULL)
00353 {
00354 delete Bitmap;
00355 Bitmap = NULL;
00356 }
00357
00358 *BM = Bitmap;
00359 return ok;
00360 }
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 BOOL StringToBitmap::TTFAddString(String_256 *text, UINT32 Xsize, UINT32 Ysize, UINT32 DPI, PLOGFONT pLogFont,
00386 INT32 IntLeading, KernelBitmap **BM, UINT32 ForeColour)
00387 {
00388 KernelBitmap *Bitmap = *BM;
00389
00390
00391
00392
00393
00394
00395
00396
00397 CDC SysDisplay;
00398 BOOL ok=SysDisplay.CreateCompatibleDC(NULL);
00399 if(!ok)
00400 {
00401
00402 ERROR3("StringToBitmap::TTF AddString: Unable to create CDC");
00403 return FALSE;
00404 }
00405
00406 HDC ScreenDC = SysDisplay.m_hDC;
00407
00408
00409 INT32 OldlfHeight = pLogFont->lfHeight;
00410 pLogFont->lfHeight = -(pLogFont->lfHeight - IntLeading);
00411
00412 UINT32 CurrentPathSizeAlloc = 0;
00413 Trans2DMatrix *pTransform = NULL;
00414 DocCoord *pPathCoords = NULL;
00415
00416 Path *pPath = NULL;
00417
00418
00419 DocCoord *pPolyCordBuffer = NULL;
00420 PathVerb *pPolyVerbBuffer = NULL;
00421 UINT32 TextLength = (UINT32)text->Length();
00422 SIZE StringSize={0,0};
00423
00424
00425
00426
00427
00428
00429 CFont UnHintedCFont;
00430 if(!UnHintedCFont.CreateFontIndirect(pLogFont))
00431 {
00432 SysDisplay.DeleteDC();
00433 pLogFont->lfHeight = OldlfHeight;
00434 return FALSE;
00435 }
00436
00437 CFont* pOldCFont=SysDisplay.SelectObject(&UnHintedCFont);
00438
00439
00440 WCHAR FontDefaultCharacter = (unsigned char)'?';
00441 TEXTMETRIC FontTextData;
00442 #ifdef _UNCCODE
00443 if (SysDisplay.GetTextMetrics(&FontTextData))
00444 FontDefaultCharacter = FontTextData.tmDefaultChar;
00445 #else
00446 if (SysDisplay.GetTextMetrics(&FontTextData))
00447 FontDefaultCharacter = (unsigned char)FontTextData.tmDefaultChar;
00448 #endif
00449
00450
00451
00452
00453 GetTextExtentPoint(ScreenDC, *text, TextLength, &StringSize);
00454
00455 if(StringSize.cy == 0)
00456 {
00457 SysDisplay.SelectObject(pOldCFont);
00458 SysDisplay.DeleteDC();
00459 pLogFont->lfHeight = OldlfHeight;
00460 return FALSE;
00461 }
00462
00463
00464 double YScale = ((double)Ysize / (double)StringSize.cy) / (double)2;
00465 double XScale = YScale;
00466
00467
00468
00469
00470
00471
00472 double YShift = 72000/100;
00473
00474 YScale = (YScale * 78) / 100;
00475 XScale = (XScale * 78) / 100;
00476
00477 if(!text->IsEmpty())
00478 {
00479 const TCHAR* pCurrentChar = (const TCHAR*)(*text);
00480
00481 while (ok && *pCurrentChar!=0)
00482 {
00483
00484 #ifdef _UNICODE
00485 WCHAR wchr = *pCurrentChar;
00486 #else
00487 UINT32 CharToConvert = 0;
00488 if (UnicodeManager::IsDBCSLeadByte(*pCurrentChar))
00489 CharToConvert = UnicodeManager::ComposeMultiBytes(*pCurrentChar, *(pCurrentChar+1));
00490 else
00491 CharToConvert = (unsigned char)(*pCurrentChar);
00492 WCHAR wchr = UnicodeManager::MultiByteToUnicode(CharToConvert);
00493 #endif
00494
00495
00496 ok = GetTextExtentPoint(ScreenDC, *text, (pCurrentChar-(TCHAR*)(*text)), &StringSize);
00497 ERROR3IF(!ok, "GetTextExtentPoint32() failed");
00498 if (!ok) break;
00499
00500
00501 DWORD PathSize = 0;
00502 ok = TextManager::GetBezierFromChar(&SysDisplay, wchr, pLogFont, &PathSize, (POINT *)NULL, (BYTE *)NULL);
00503 if (!ok)
00504 {
00505 wchr = FontDefaultCharacter;
00506 ok = TextManager::GetBezierFromChar(&SysDisplay, wchr, pLogFont, &PathSize, (POINT *)NULL, (BYTE *)NULL);
00507 }
00508 ERROR3IF(!ok, "GetBezierFromChar returned false");
00509 if (!ok) break;
00510
00511
00512 if(pPolyCordBuffer == NULL)
00513 {
00514 TRY
00515 {
00516 pPolyCordBuffer = new DocCoord[PathSize];
00517 }
00518 CATCH (CMemoryException, e)
00519 {
00520 pPolyCordBuffer = NULL;
00521
00522 }
00523 END_CATCH
00524 }
00525
00526
00527 if(pPolyVerbBuffer == NULL)
00528 {
00529 TRY
00530 {
00531 pPolyVerbBuffer = new PathVerb[PathSize];
00532 }
00533 CATCH (CMemoryException, e)
00534 {
00535 pPolyVerbBuffer = NULL;
00536
00537 }
00538 END_CATCH
00539 }
00540
00541 if (pPolyCordBuffer == NULL || pPolyVerbBuffer == NULL)
00542 {
00543 ok = FALSE;
00544 break;
00545 }
00546
00547 CurrentPathSizeAlloc = PathSize;
00548
00549
00550 ok = TextManager::GetBezierFromChar(&SysDisplay, wchr, pLogFont, &PathSize, (POINT *)pPolyCordBuffer,
00551 (BYTE *)pPolyVerbBuffer);
00552 if(!ok) TRACEUSER( "Richard", _T("GetBezierFromChar returned false in second phase...\n"));
00553 if(!ok) break;
00554
00555
00556 if((PathSize > 0))
00557 {
00558 pPath = new Path();
00559 pPath->Initialise(PathSize, 12);
00560 pPath->CopyPathDataFrom(pPolyCordBuffer, pPolyVerbBuffer, PathSize, TRUE);
00561
00562
00563 Matrix scale(XScale, 0, 0, YScale, (INT32)((XScale*StringSize.cx*72000)/(double)DPI), (INT32)YShift);
00564
00565 pTransform = new Trans2DMatrix(scale);
00566 pPathCoords = pPath->GetCoordArray();
00567 pTransform->Transform( pPathCoords, pPath->GetNumCoords() );
00568 delete pTransform;
00569
00570 pPath->InitialiseFlags();
00571
00572 ok = ALU->GradFillPath(pPath, ForeColour, ForeColour, 0, 0, 0, Ysize, S2BMP_ANTIALIAS);
00573 ERROR3IF(!ok, "Gradfillpath returned false");
00574 if(!ok) break;
00575
00576 delete pPath;
00577 }
00578
00579
00580
00581 if(CurrentPathSizeAlloc != S2BMP_MAGIC)
00582 {
00583 delete []pPolyCordBuffer;
00584 delete []pPolyVerbBuffer;
00585
00586 pPolyCordBuffer = NULL;
00587 pPolyVerbBuffer = NULL;
00588 CurrentPathSizeAlloc = 0;
00589 }
00590
00591 pPath = NULL;
00592 pTransform = NULL;
00593
00594 pCurrentChar = camStrinc(pCurrentChar);
00595 }
00596 }
00597
00598
00599 if(pPolyCordBuffer != NULL) delete []pPolyCordBuffer;
00600 if(pPolyVerbBuffer != NULL) delete []pPolyVerbBuffer;
00601 if(pPath != NULL) delete pPath;
00602 if(pTransform != NULL) delete pTransform;
00603
00604
00605
00606
00607
00608
00609 SysDisplay.SelectObject(pOldCFont);
00610
00611
00612
00613 SysDisplay.DeleteDC();
00614
00615 pLogFont->lfHeight = OldlfHeight;
00616
00617 return ok;
00618 }
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645 BOOL StringToBitmap::AddString(String_256 *text, UINT32 Xsize, UINT32 Ysize, UINT32 DPI, PLOGFONT pLogFont,
00646 INT32 IntLeading, KernelBitmap **BM, UINT32 ForeColour, FontClass Type)
00647 {
00648 ERROR3IF(text == NULL, "StringToBitmap::AddString given null text pointer");
00649 ERROR3IF(pLogFont == NULL, "StringToBitmap::AddString given null logfont pointer");
00650 ERROR3IF(BM == NULL, "StringToBitmap::AddString given null bmp pointer");
00651 if(text == NULL || pLogFont == NULL || BM == NULL)
00652 return FALSE;
00653
00654 KernelBitmap *Bitmap = *BM;
00655
00656 FontInfo info;
00657 BOOL ok=TextManager::GetInfoFromLogFont(&info, pLogFont, Type);
00658 if (!ok)
00659 {
00660 ERROR3("StringToBitmap::ATMAddString problems getting font handle");
00661 return FALSE;
00662 }
00663
00664 BOOL Bold = info.Bold;
00665 BOOL Italic = info.Italic;
00666 WORD TypeFaceHandle = info.Handle;
00667
00668 CDC SysDisplay;
00669 ok=SysDisplay.CreateCompatibleDC(NULL);
00670 if(!ok)
00671 {
00672 ERROR3("StringToBitmap::AddString: Unable to create CDC");
00673 return FALSE;
00674 }
00675
00676 HDC ScreenDC = SysDisplay.m_hDC;
00677
00678 Trans2DMatrix *pTransform = NULL;
00679 UINT32 ChNum = 0;
00680 DocCoord *pPathCoords = NULL;
00681
00682 Path *pPath = NULL;
00683
00684 DocCoord *pPolyCordBuffer = NULL;
00685 PathVerb *pPolyVerbBuffer = NULL;
00686 UINT32 TextLength = (UINT32)text->Length();
00687 SIZE StringSize={0,0};
00688
00689
00690 LOGFONT CharLogFont;
00691 CharDescription DummyChar(TEXT('A'), TypeFaceHandle, Bold, Italic);
00692 ok=TextManager::GetLogFontFromCharDescriptor(&SysDisplay, DummyChar, &CharLogFont);
00693
00694 CFont UnHintedCFont;
00695 if(!UnHintedCFont.CreateFontIndirect(&CharLogFont))
00696 {
00697 SysDisplay.DeleteDC();
00698 return FALSE;
00699 }
00700
00701 CFont* pOldCFont=SysDisplay.SelectObject(&UnHintedCFont);
00702
00703
00704
00705 if(!GetTextExtentPoint(ScreenDC, *text, TextLength, &StringSize))
00706 {
00707 SysDisplay.SelectObject(pOldCFont);
00708 SysDisplay.DeleteDC();
00709 return FALSE;
00710 }
00711
00712 if(StringSize.cy == 0)
00713 {
00714 SysDisplay.SelectObject(pOldCFont);
00715 SysDisplay.DeleteDC();
00716 return FALSE;
00717 }
00718
00719 double YScale = ((double)Ysize / (double)StringSize.cy) / (double)2;
00720 YScale = (YScale * 78) / 100;
00721 double XScale = YScale;
00722 double XSpacing = (XScale * 72000) / (double)DPI;
00723
00724
00725
00726
00727
00728
00729 double YShift = 72000/100;
00730
00731 UINT32 NumCoords = 0;
00732
00733 if(!text->IsEmpty())
00734 {
00735 const TCHAR* pCurrentChar = (const TCHAR*)(*text);
00736
00737 while (ok && *pCurrentChar!=0)
00738 {
00739
00740 #ifdef _UNICODE
00741 WCHAR wchr = *pCurrentChar;
00742 #else
00743 UINT32 CharToConvert = 0;
00744 if (UnicodeManager::IsDBCSLeadByte(*pCurrentChar))
00745 CharToConvert = UnicodeManager::ComposeMultiBytes(*pCurrentChar, *(pCurrentChar+1));
00746 else
00747 CharToConvert = (unsigned char)(*pCurrentChar);
00748 WCHAR wchr = UnicodeManager::MultiByteToUnicode(CharToConvert);
00749 #endif
00750
00751
00752 ok = GetTextExtentPoint(ScreenDC, *text, (pCurrentChar-(TCHAR*)(*text)), &StringSize);
00753 ERROR3IF(!ok, "GetTextExtentPoint32() failed");
00754 if (!ok) break;
00755
00756 CharDescription CharDesc(wchr, TypeFaceHandle, Bold, Italic);
00757 NumCoords = 0;
00758
00759 ok = OILFontMan::GetCharPath(Type, CharDesc, &pPolyCordBuffer, &pPolyVerbBuffer, &NumCoords, NULL);
00760 if(!ok) break;
00761
00762
00763 if((NumCoords > 0))
00764 {
00765 pPath = new Path();
00766 pPath->Initialise(NumCoords, 12);
00767 pPath->CopyPathDataFrom(pPolyCordBuffer, pPolyVerbBuffer, NumCoords, TRUE);
00768
00769
00770 Matrix scale(XScale, 0, 0, YScale, (INT32)(XSpacing * (double)StringSize.cx), (INT32)YShift);
00771
00772 pTransform = new Trans2DMatrix(scale);
00773 pPathCoords = pPath->GetCoordArray();
00774 pTransform->Transform( pPathCoords, pPath->GetNumCoords() );
00775 delete pTransform;
00776
00777 pPath->InitialiseFlags();
00778
00779 ok = ALU->GradFillPath(pPath, ForeColour, ForeColour, 0, 0, 0, Ysize, S2BMP_ANTIALIAS);
00780 ERROR3IF(!ok, "Gradfillpath returned false");
00781 if(!ok) break;
00782
00783 delete pPath;
00784 }
00785
00786 pPath = NULL;
00787 pTransform = NULL;
00788
00789 pCurrentChar = camStrinc(pCurrentChar);
00790 }
00791 }
00792
00793
00794 if(pPath != NULL) delete pPath;
00795 if(pTransform != NULL) delete pTransform;
00796
00797
00798 SysDisplay.SelectObject(pOldCFont);
00799 SysDisplay.DeleteDC();
00800
00801 return ok;
00802 }
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832 BOOL StringToBitmap::MakeBitmap(String_256 *text, UINT32 Xsize, UINT32 Ysize, UINT32 BPP, UINT32 DPI,
00833 PLOGFONT pLogFont, INT32 IntLeading, KernelBitmap **BM, FontClass Type, PathName *Filename)
00834 {
00835 ERROR3IF(text == NULL, "StringToBitmap::MakeBitmap given null text pointer");
00836 ERROR3IF(pLogFont == NULL, "StringToBitmap::MakeBitmap given null logfont pointer");
00837 ERROR3IF(BM == NULL, "StringToBitmap::MakeBitmap given null bmp pointer");
00838 if(text == NULL || pLogFont == NULL || BM == NULL)
00839 return FALSE;
00840
00841
00842 BOOL ok = TRUE;
00843
00844
00845 KernelBitmap *Bitmap = NULL;
00846
00847 #if 0
00848
00849 DialogColourInfo DCol;
00850 DocColour DialogBack = DCol.TextBack();
00851 INT32 Red, Green, Blue;
00852 DialogBack.GetRGBValue(&Red, &Green, &Blue);
00853 DWORD BackColRef = (DWORD) Red;
00854 BackColRef |= ((DWORD)Green) << 8;
00855 BackColRef |= ((DWORD)Blue) << 16;
00856 #endif
00857
00858
00859
00860 if(!BlankBitmap(Xsize, Ysize, 32, S2BMP_BACKGROUND_COLOUR, &Bitmap))
00861 {
00862 ERROR3("BlankBitmap returned false");
00863 return FALSE;
00864 }
00865
00866
00867 *BM = Bitmap;
00868
00869
00870 if(!AddString(text, Xsize, Ysize, DPI, pLogFont, IntLeading, &Bitmap, S2BMP_FOREGROUND_COLOUR, Type))
00871 {
00872 Error::ClearError();
00873 ERROR3("Addstring returned false");
00874 return FALSE;
00875 }
00876 Error::ClearError();
00877
00878
00879 if(BPP == 8)
00880 {
00881 ALU->SetB(Bitmap);
00882 KernelBitmap *pNewBitmap = NULL;
00883
00884 if(ALU->MakeGreyscale32to8(&pNewBitmap))
00885 {
00886 if(pNewBitmap != NULL)
00887 {
00888 delete Bitmap;
00889 ContoneFontBitmap(pNewBitmap);
00890 Bitmap = pNewBitmap;
00891 *BM = Bitmap;
00892 }
00893 }
00894 }
00895
00896
00897 if(Filename != NULL)
00898 {
00899
00900 ok = StringToBitmap::SaveBitmap(Bitmap, Filename);
00901 if(!ok) TRACEUSER( "Richard", _T("Failed to save thumbnail file"));
00902 }
00903
00904 return ok;
00905 }
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922 BOOL StringToBitmap::ContoneFontBitmap(KernelBitmap *pBitmap)
00923 {
00924 ERROR3IF(pBitmap == NULL, "StringToBitmap::ContoneFontBitmap given a NULL param");
00925
00926 if(pBitmap->GetBPP() != 8)
00927 return FALSE;
00928
00929 if(!SuperGallery::UseFixedColourSet)
00930 {
00931 RGBQUAD Pal;
00932 RGBQUAD Start;
00933 RGBQUAD End;
00934 INT32 Red, Green, Blue;
00935 DialogColourInfo RedrawColours;
00936
00937 DocColour TmpCol = RedrawColours.TextFore();
00938 TmpCol.GetRGBValue(&Red, &Green, &Blue);
00939
00940 Start.rgbRed = (BYTE)Red;
00941 Start.rgbGreen = (BYTE)Green;
00942 Start.rgbBlue = (BYTE)Blue;
00943 Start.rgbReserved = 0;
00944
00945 TmpCol = RedrawColours.TextBack();
00946 TmpCol.GetRGBValue(&Red, &Green, &Blue);
00947
00948 End.rgbRed = (BYTE)Red;
00949 End.rgbGreen = (BYTE)Green;
00950 End.rgbBlue = (BYTE)Blue;
00951 End.rgbReserved = 0;
00952
00953 RGBQUAD *DestPal = ((WinBitmap *)pBitmap->ActualBitmap)->BMInfo->bmiColors;
00954
00955 for(INT32 x=0; x<=255; x++)
00956 {
00957 Pal.rgbRed = (BYTE)(Start.rgbRed + (INT32)(((float)(End.rgbRed - Start.rgbRed) / 256.0) * x) & 255);
00958 Pal.rgbGreen = (BYTE)(Start.rgbGreen + (INT32)(((float)(End.rgbGreen - Start.rgbGreen) / 256.0) * x) & 255);
00959 Pal.rgbBlue = (BYTE)(Start.rgbBlue + (INT32)(((float)(End.rgbBlue - Start.rgbBlue) / 256.0) * x) & 255);
00960 Pal.rgbReserved = 0;
00961
00962 DestPal[x] = Pal;
00963 }
00964
00965
00966
00967 DestPal[0] = Start;
00968 DestPal[253] = End;
00969 DestPal[254] = End;
00970 DestPal[255] = End;
00971 }
00972
00973 return TRUE;
00974 }
00975 #endif