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".

  • to save memory in my paradox blob Just setting the PixelFormat to pf1bit will change the scanlines but your palette is likely wrong Yes pf1bit bitmaps have a palette This seems to work in defining a black white palette procedure TForm1 Button1Click Sender TObject VAR Bitmap TBitmap Palette TMaxLogPalette BEGIN Palette palVersion 300 Palette palNumEntries 2 WITH Palette palPalEntry 0 DO BEGIN peRed 0 peGreen 0 peBlue 0 peFlags 0

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



  • P X 0 that s black The right number is 000000000000000 11111111 end If your bitmap can t set to 24 bits you have to work on the palette var pal PLogPalette Buffer Palette img2pal PlogPalette Palette of image2 hpal HPALETTE Handle to a new palette h2pal HPALETTE Handle of image2 palette i Integer x Integer begin Reset variables pal nil img2pal nil try Takes place in memory to the palettes GetMem img2pal sizeof TLogPalette sizeof TPaletteEntry 255 GetMem pal sizeof TLogPalette sizeof TPaletteEntry 255 pal palVersion 300 pal palNumEntries 256 256 colors img2pal palVersion 300 img2pal palNumEntries 256 Scan the entries of the palette and reset it for i 0 to 255 do begin img2pal palPalEntry i peRed 0 img2pal palPalEntry i peGreen 0 img2pal palPalEntry i peBlue 0 end read the entries from the image the buffer image x 0 x getpaletteentries Image2 picture Bitmap Palette 0 255 img2pal palPalEntry x getpaletteentries Bitmap Palette 0 255 img2pal palPalEntry if x 0 then begin Showmessage Funcion falla function fails exit end Now shift the entries by adding 4 You can change this value for i 0 to 255 do begin pal palPalEntry i pered img2pal palPalEntry i pered shiftvalue

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


  • a 256 color bitmap palette From Bob Villiers This topic got a good airing last month under How can I change a color in a bitmap palette Here is how to load a 256 bitmap change the first palette entry to blue and display the changed bitmap Var bmp TBitmap NewCol TRGBQuad begin bmp TBitmap Create bmp LoadFromFile chemical bmp NewCol rgbBlue 255 NewCol rgbGreen 0 NewCol rgbRed 0 NewCol

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


  • dependent bitmap because the pixels of an 8 bpp DDB refer to palette indices In contrast the pixels of an 8 bpp DIB section bitmap refer to color table indices This color table actually plays an important role in the DIB section s device independence the DI in DIB stands for device independent because if the DIB section s pixels did refer to palette indices the DIB section would depend on that palette which itself is inherently linked to a specific device Because an 8 bpp DIB section s pixels refer color table indices when you draw this DIB section on a palettized display the GDI must map color table indices to palette indices which it does by using the distance formula If the color table contains the same entries as the palette then 1 there s no additional mapping involved and 2 the bitmap will draw faster Now if you change only a palette entry but you don t change the corresponding color table entry you haven t actually changed the color that the bitmap s corresponding pixels refers to For example if the first entry of both the palette and the color table refer to lime green and you change only the palette entry to say blue then the pixels of the bitmap that refer to lime green won t be drawn in blue instead they ll be drawn in the color of the palette that matches closest in distance to lime green Does this make sense So in short after you change your Bitmap s palette you also need to change it s color table via the SetDIBColorTable function Here s an example void fastcall TForm1 ScrollBar1Scroll TObject Sender TScrollCode ScrollCode int ScrollPos NOTE Bitmap is your TBitmap object grab a handle to the bitmap s logical

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


  • P Calculate the first line all future lines share the same data For X 1 to sWidth do Begin Pre calculate some more repeated math Speed1 sWidth X Speed2 DestX X 1 We switch blue red to compensate for RGB vs BGR P Speed2 mRed Speed1 sRGB mBlue X dRGB mBlue div sWidth P Speed2 mGreen Speed1 sRGB mGreen X dRGB mGreen div sWidth P Speed2 mBlue Speed1 sRGB mRed X dRGB mRed div sWidth End For Y 1 to sHeight 1 do Begin Duplicate source line for cover image height Move P DestX P2 DestX sWidth 3 Inc Integer P2 PDif end end procedure sGradientRectV DestBitmap TBitmap DestX DestY sWidth sHeight sRGB1 sRGB2 TColor var sRGB TMyRGB dRGB TMyRGB P TMyScanLine PDif Integer Speed1 Integer Y X Integer begin Dirty way to convert TColor to an RGB Move sRGB1 sRGB 3 Move sRGB2 dRGB 3 Calculate memory used for each line display for quick scanline seeks P DestBitmap ScanLine DestY PDif Integer DestBitmap ScanLine DestY 1 Integer P For Y 0 to sHeight 1 do Begin Pre calculate some more repeated math Speed1 sHeight Y We switch blue red to compensate for RGB vs BGR P DestX mRed Speed1 sRGB mBlue Y dRGB mBlue div sHeight P DestX mGreen Speed1 sRGB mGreen Y dRGB mGreen div sHeight P DestX mBlue Speed1 sRGB mRed Y dRGB mRed div sHeight Fill color through the rest of the line For X 1 to sWidth 1 do P DestX X P DestX Inc Integer P PDif End end a procedure to smoothly downsize a TBitmap can upsize too but not very well copies a bitmap into a rectangle within a second bitmap procedure ImageFactorReize SrcBitmap DestBitmap TBitmap DestX DestY dWidth dHeight Integer var Speed1 Integer Speed2 Integer Speed4 Integer PixR Integer PixG Integer

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


  • here is some sample code procedure TForm1 FormPaint Sender TObject var vert array 0 2 of TRIVERTEX gRect GRADIENT RECT gTri GRADIENT TRIANGLE begin vert 0 x PaintBox1 Left vert 0 y PaintBox1 Top vert 0 Red ff00 vert 0 Green 0000 vert 0 Blue 0000 vert 0 Alpha 0000 vert 1 x PaintBox1 Left PaintBox1 Width vert 1 y PaintBox1 Top vert 1 Red 0000 vert 1 Green 0000

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


  • 0 Reply To anders melander dk Newsgroups borland public delphi graphics eengler zcsterling com Eric W Engler wrote You can use Paintshop Pro to do the conversion It can give you an optimum palette of colors that includes the 20 windows colors This gives great results TGIFImage can do this too uses graphics gifimage var GIF TGIFImage Bitmap TBitmap begin GIF TGIFImage Create Bitmap TBitmap Create try Bitmap LoadFromFile manycolors

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


  • Set the TImage to Autosize true I gave the buttons long names that describe what they do I use two TBitmaps one is 24bit and one is 8bit The open picture routine opens any TPicture and copies it into the 24 bit bitmap The convert save button uses a temporary TJPEGImage to do color reduction then copies that into the 8 bit bitmap It gives you an opportunity to save it make sure you specify filename bmp or limit the save dialog to type bmp For clarity of code no error checking is done unit Unit1 interface uses Windows Messages SysUtils Classes Graphics Controls Forms Dialogs jpeg StdCtrls ExtDlgs ExtCtrls type TForm1 class TForm Image1 TImage OpenPictureDialog1 TOpenPictureDialog OpenPictureButton TButton ConvertAndSave8BitBitmapButton TButton SavePictureDialog1 TSavePictureDialog procedure OpenPictureButtonClick Sender TObject procedure FormCreate Sender TObject procedure FormDestroy Sender TObject procedure ConvertAndSave8BitBitmapButtonClick Sender TObject private Private declarations bmp24bit TBitmap bmp8bit TBitmap public Public declarations end var Form1 TForm1 implementation R DFM procedure TForm1 OpenPictureButtonClick Sender TObject begin if OpenPictureDialog1 Execute then begin Image1 Picture LoadFromFile OpenPictureDialog1 Filename bmp24bit Width Image1 Picture Width bmp24bit Height Image1 Picture Height bmp24bit PixelFormat pf24bit bmp24bit Canvas Draw 0 0 Image1 Picture Graphic end end procedure TForm1 FormCreate Sender

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



  •