archive-com.com » COM » E » EFG2.COM

Total: 878

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".

  • TColor TColor CONST ColorList ARRAY 0 15 OF TColor clBlack clMaroon clGreen clOlive clNavy clPurple clTeal clGray clSilver clRed clLime clYellow clBlue clFuchsia clAqua clWhite VAR DistanceSquared INTEGER B1 B2 INTEGER G1 G2 INTEGER i INTEGER R1 R2 INTEGER SmallestDistanceSquared INTEGER BEGIN RESULT clBlack Assume black is closest color SmallestDistanceSquared 256 256 256 Any distance would be shorter R1 GetRValue color G1 GetGValue color B1 GetBValue color FOR i 0

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/Graphics/NearestColor.TXT (2016-02-14)
    Open archived version from archive



  • can anyone provide a small piece of code that creates the standard 256 color palette for windows I d like to have a palette window in my program but I can t figure out how the get the standard palette This solution is brought to you by Joe Hecht s TExcellent products solving Form Print and bitmap printing problems Joe Hecht s TExcellent products can be found at www code4sale com joehecht index htm There is no standard 256 color palette Microsoft does publish a suggested palette hoever not all drivers follow the spec Basically the first 10 are your system colors and the last 10 are the inverse of the first 10 System colors can be set by the user via desktop theme s or simply by setting them one by one The remaining 236 colors are ususally not set garbage until a 256 color bitmap is loaded then the colors are collapsed to a best fit You may want a wash palette where the colors are chosen to provide a wide range of colors suitibile for displaying images in general however using a wash palette is also not ideal for all images and for some images may be

    Original URL path: http://www.efg2.com/Lab/Library/UseNet/2001/0816a.txt (2016-02-14)
    Open archived version from archive


  • word Height to stretch bm TBitmap the TBitmap to Blt var OriginalWidth LongInt width of BM dc hdc screen dc IsPaletteDevice bool if the device uses palettes IsDestPaletteDevice bool if the device uses palettes BitmapInfoSize integer sizeof the bitmapinfoheader lpBitmapInfo PBitmapInfo the bitmap info header hBm hBitmap handle to the bitmap hPal hPalette handle to the palette OldPal hPalette temp palette hBits THandle handle to the DIB bits pBits pointer pointer to the DIB bits lPPalEntriesArray PPalEntriesArray palette entry array NumPalEntries integer number of palette entries i integer looping variable begin If range checking is on lets turn it off for now we will remember if range checking was on by defining a define called CKRANGE if range checking is on We do this to access array members past the arrays defined index range without causing a range check error at runtime To satisfy the compiler we must also access the indexes with a variable ie if we have an array defined as a array 0 0 of byte and an integer i we can now access a 3 by setting i 3 and then accessing a i without error IFOPT R DEFINE CKRANGE R ENDIF Save the original width of the bitmap OriginalWidth bm Width Get the screen s dc to use since memory dc s are not reliable dc GetDc 0 Are we a palette device IsPaletteDevice GetDeviceCaps dc RASTERCAPS and RC PALETTE RC PALETTE Give back the screen dc dc ReleaseDc 0 dc Allocate the BitmapInfo structure if IsPaletteDevice then BitmapInfoSize sizeof TBitmapInfo sizeof TRGBQUAD 255 else BitmapInfoSize sizeof TBitmapInfo GetMem lpBitmapInfo BitmapInfoSize Zero out the BitmapInfo structure FillChar lpBitmapInfo BitmapInfoSize 0 Fill in the BitmapInfo structure lpBitmapInfo bmiHeader biSize sizeof TBitmapInfoHeader lpBitmapInfo bmiHeader biWidth OriginalWidth lpBitmapInfo bmiHeader biHeight bm Height lpBitmapInfo bmiHeader biPlanes 1 if IsPaletteDevice then lpBitmapInfo bmiHeader biBitCount 8 else lpBitmapInfo bmiHeader biBitCount 24 lpBitmapInfo bmiHeader biCompression BI RGB lpBitmapInfo bmiHeader biSizeImage lpBitmapInfo bmiHeader biWidth longint lpBitmapInfo bmiHeader biBitCount div 8 lpBitmapInfo bmiHeader biHeight lpBitmapInfo bmiHeader biXPelsPerMeter 0 lpBitmapInfo bmiHeader biYPelsPerMeter 0 if IsPaletteDevice then begin lpBitmapInfo bmiHeader biClrUsed 256 lpBitmapInfo bmiHeader biClrImportant 256 end else begin lpBitmapInfo bmiHeader biClrUsed 0 lpBitmapInfo bmiHeader biClrImportant 0 end Take ownership of the bitmap handle and palette hBm bm ReleaseHandle hPal bm ReleasePalette Get the screen s dc to use since memory dc s are not reliable dc GetDc 0 if IsPaletteDevice then begin If we are using a palette it must be selected into the dc during the conversion OldPal SelectPalette dc hPal TRUE Realize the palette RealizePalette dc end Tell GetDiBits to fill in the rest of the bitmap info structure GetDiBits dc hBm 0 lpBitmapInfo bmiHeader biHeight nil TBitmapInfo lpBitmapInfo DIB RGB COLORS Allocate memory for the Bits hBits GlobalAlloc GMEM MOVEABLE lpBitmapInfo bmiHeader biSizeImage pBits GlobalLock hBits Get the bits GetDiBits dc hBm 0 lpBitmapInfo bmiHeader biHeight pBits TBitmapInfo lpBitmapInfo DIB RGB COLORS if IsPaletteDevice then begin Lets fix up the color table for buggy video drivers GetMem lPPalEntriesArray sizeof TPaletteEntry 256 IFDEF

    Original URL path: http://www.efg2.com/Lab/Library/UseNet/1997/1026.txt (2016-02-14)
    Open archived version from archive


  • on the palette colors So if you want an xor mask xor transparency operation to work you have to make sure that the palette entries at palette index N and xor inverse of N contain colors that are xor inverses of each other yes it s insane As to your comment about the reserved system colors being constant those color values can vary from one machine to the next In particular some video drivers have a bad habit of setting the system colors to values that are not xor inverses of each other so xor transparency fails This was a major problem in Win 3 1 and Win 95 but less so now That may just be because fewer people are using palette based video modes now Danny Thorpe Delphi R D Steve Bliss wrote In Delphi 3 only 4 16 24 32 bit color work correctly for transparancy 8 bit does not I do not know if this is a Delphi or Windows problem There is probably a much simpler way around this but for what it is worth I got around it by double buffering my output to the screen i e before any palletes get in the

    Original URL path: http://www.efg2.com/Lab/Library/UseNet/1999/0415c.txt (2016-02-14)
    Open archived version from archive


  • Produced By Microsoft MimeOLE V5 50 4522 1200 NNTP Posting Host 24 17 126 157 Message ID X Trace 27 Mar 2001 18 23 28 0800 24 17 126 157 Path dnews 24 17 126 157 Xref dnews borland public delphi graphics 36796 Bad very bad Bitmaps with palettes having a stated number of colors other than the default will save incorrectly and will crash or refuse to load in

    Original URL path: http://www.efg2.com/Lab/Library/UseNet/2001/0327a.txt (2016-02-14)
    Open archived version from archive


  • re in 256 color mode and you resize a TBitmap a palette is always created even if PixelFormat pf24Bit So when you save a modified 24Bit bitmap to disk the unnecessary palette is saved too Apparently Delphi can read this corrupt bitmap but other programs that expect a standard bitmap display it all wrong The solution is to set the Palette to 0 before saving it i e Bitmap Palette 0 Thomas Munk wrote Hello Delphi group I was wondering if someone could give me some guidelines for handling the following job in Delphi 3 I want my program to generate one bitmap containing several thumbnails of other bitmaps This final thumb bitmap should be 24 bit colours no matter what colour depth the computer runs at generation time The bitmaps to be thumbnailed are both 24 bit and other depths What I do today is this B TBitmap Create B PixelFormat pf24bit Set B Width and B Height to 500 x 480 Putting in the small thumbnails with B Canvas Draw Maybe assigning B Width and or B Height smaller values B SaveToFile I works allright most of the time but here s my problem If the computer runs

    Original URL path: http://www.efg2.com/Lab/Library/UseNet/1999/0412b.txt (2016-02-14)
    Open archived version from archive


  • palette changes do not seem to occur The image is the same Is there something else I should do Is your display running at a color depth of 8 bpp or less A palette is only used when the color depth of the screen on which the Bitmap is displayed is 8 bpp or less Even though the Bitmap s Palette property is non NULL unless its needed the palette is not used Now as of BCB3 the TBitmap class uses DIBSections DIBSections contain both bitmap DDB and DIB parts If your TBitmap is 8 bpp then the corresponding DIBSection is 8 bpp also and the DIB part has a corresponding color table which you can modify in much the same way as you would a palette For example Graphics TBitmap Bitmap Image1 Picture Bitmap RGBQUAD rgbQ 256 memset rgbQ 0 256 if GetDIBColorTable Bitmap Canvas Handle 0 256 rgbQ for int index 0 index Canvas Handle 0 256 rgbQ Image1 Invalidate The problem now is that when you re indeed running in 8 bpp or less you will need a palette If you modify just the color table entries the palette and color table are no longer in sync

    Original URL path: http://www.efg2.com/Lab/Library/UseNet/2000/0710.txt (2016-02-14)
    Open archived version from archive


  • port of call but alas couldn t find anything relevant I should have looked harder I read your scanline articles and developed a solution which I post here You are free to use this example on your site if you wish The only caveat on this routine is that the source bitmap must be a 256 colour bitmap Cheers Laurie procedure Change256ColorBitmapPalette var ABitmap TBitmap ANewLogPalette PLogPalette var i j

    Original URL path: http://www.efg2.com/Lab/Library/UseNet/1999/1008a.txt (2016-02-14)
    Open archived version from archive



  •