Saving Palette Info With Bitmaps


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Saving Palette Info With Bitmaps

  1. #1
    Barnett Williams Guest

    Saving Palette Info With Bitmaps


    Hello

    I need help with saving palette information when saving an 8-bit bitmap.
    I am successfully creating a palette (of type LOGPALETTE), however, when
    I do my

    Open m_SaveFileName For Binary As fNum
    Put fNum, , SaveFileHeader
    Put fNum, , SaveBitmapInfo_8
    Put fNum, , SaveBits()
    Close fNum

    and then look at the saved bitmap's palette, it still has the default system
    palette embedded within. I am also trying to use the CreatePalette, SelectPalette,
    and RealizePalette functions, but they don't seem to be doing anything.

    If anyone could explain to me what I am doing wrong, it would be greatly
    appreciated. Thanks.


  2. #2
    Jim Deutch Guest

    Re: Saving Palette Info With Bitmaps

    I recognize that code! <g>

    You're missing one little concept here: GetDIBits() always applies a
    standard halftone palette to whatever color data is available, doing a
    nearest-color match (not a fancy dither). Doesn't matter what palette
    the bitmap in the device context had before you turned it into bits via
    GetDIBits().

    The only way I've found to apply a non-standard palette is to use
    GetDIBits() at 24- or 32-bit color depth, then use my own nearest-color
    algorithm, and build the .biColors() array and the pixel array in 8-bit
    mode "by hand". It's kinda slow...

    Jim Deutch

    Barnett Williams wrote in message <39d0e6ea$1@news.devx.com>...
    >
    >Hello
    >
    >I need help with saving palette information when saving an 8-bit

    bitmap.
    > I am successfully creating a palette (of type LOGPALETTE), however,

    when
    >I do my
    >
    > Open m_SaveFileName For Binary As fNum
    > Put fNum, , SaveFileHeader
    > Put fNum, , SaveBitmapInfo_8
    > Put fNum, , SaveBits()
    > Close fNum
    >
    >and then look at the saved bitmap's palette, it still has the default

    system
    >palette embedded within. I am also trying to use the CreatePalette,

    SelectPalette,
    >and RealizePalette functions, but they don't seem to be doing anything.
    >
    >If anyone could explain to me what I am doing wrong, it would be

    greatly
    >appreciated. Thanks.
    >




  3. #3
    Mike D Sutton Guest

    Re: Saving Palette Info With Bitmaps

    > The only way I've found to apply a non-standard palette is to use
    > GetDIBits() at 24- or 32-bit color depth, then use my own nearest-color
    > algorithm, and build the .biColors() array and the pixel array in 8-bit
    > mode "by hand". It's kinda slow...


    You'll probably find the page:
    http://vbaccelerator.com/codelib/gfx/clrman2.htm
    To be useful if you going to be dithering from 24+ bit colour manually.
    Hope this helps,

    Mike


    -- EDais --

    WWW: Http://Members.xoom.com/EDais/
    Work E-Mail: EDais@btinternet.com
    Other E-Mail: Frankle@btinternet.com



  4. #4
    Barnett Williams Guest

    Re: Saving Palette Info With Bitmaps


    Thank you both! I was able to finally get the main functionality of my program
    to work correctly. It's a good feeling.

    Barnett Williams


    "Mike D Sutton" <Frankle@btinternet.com> wrote:
    >> The only way I've found to apply a non-standard palette is to use
    >> GetDIBits() at 24- or 32-bit color depth, then use my own nearest-color
    >> algorithm, and build the .biColors() array and the pixel array in 8-bit
    >> mode "by hand". It's kinda slow...

    >
    >You'll probably find the page:
    >http://vbaccelerator.com/codelib/gfx/clrman2.htm
    >To be useful if you going to be dithering from 24+ bit colour manually.
    >Hope this helps,
    >
    > Mike
    >
    >
    > -- EDais --
    >
    >WWW: Http://Members.xoom.com/EDais/
    >Work E-Mail: EDais@btinternet.com
    >Other E-Mail: Frankle@btinternet.com
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center