How to save a new palette in a bmp file 
Author Message
 How to save a new palette in a bmp file

Hi,

- I must save a bmp file with a new palette loaded (reading a file .map
used by Winfract and Fractint). I'm not able to save the picture
displayed in picture-box using the "savepicture" instruction, because it
saves the original bmp file and not the original file with palette
changes. The picture.image property doesn't seem to work because the
saved bmp is all "black"!

- Can someone tell me something about it? Is there another way to save
bmp insted of using the "savepicture" instruction?

Thank you very much.

--
Paolo Guagliumi
_______________________________________
Casale Monferrato - Alessandria - Italy

http://www.*-*-*.com/



Wed, 24 Oct 2001 03:00:00 GMT  
 How to save a new palette in a bmp file

Quote:

>- I must save a bmp file with a new palette loaded (reading a file .map
>used by Winfract and Fractint). I'm not able to save the picture
>displayed in picture-box using the "savepicture" instruction, because it
>saves the original bmp file and not the original file with palette
>changes. The picture.image property doesn't seem to work because the
>saved bmp is all "black"!

I recognize that.

Quote:
>- Can someone tell me something about it? Is there another way to save
>bmp insted of using the "savepicture" instruction?

Well... I've tried saving a bitmap, based upon the code from Appleman's
API book, to print the contents of the picture box. Dispite the fact
that it "works", the results even for the .picture property are not as
good than doing a plain savepicture(). I'm not sure why, but the palette
seems to be a bit off.

If you only want to replace the palette, why don't you simply overwrite
it in (a copy of) the original BMP file? It's not that hard.

The palette starts at seek value (1 for VB) + (14 for the file header) +
(40 for the BMPINFOHEADER) = 55. The palette itself is in RGBQUADs, i.e.

    Type RGBQUAD
        rgbBlue As Byte
        rgbGreen As Byte
        rgbRed As Byte
        rgbReserved As Byte   'zero
    End Type

The number of palette entries (paldepth) is given by the value of the
field .biClrUsed if this is not zero, otherwise it's 2^.biBitCount if
.biBitCount is at most 8. There's no palette if there are more bits per
pixel than 8.

So basically, this is what you need:

        dim handle%: handle = FreeFile
        open BMPfile for binary as #handle
        Seek #handle, 55
        Dim j%
        For j = 0 to paldepth - 1
                Put #handle, ,palRGBQuad(j)
        Next
        Close #handle

   HTH,
   Bart.



Thu, 25 Oct 2001 03:00:00 GMT  
 How to save a new palette in a bmp file
Hi all and a BIG, BIG, BIG thank to all and especially to Bart Lateur
and Tm4321

I found a solution about saving .bmp images in my project using these
few code lines

Clipboard.Clear
Clipboard.SetData Form1.Picture2.Picture 'I copy the picture in the
clipboard
Form2.Picture1.Picture = Clipboard.GetData(2) 'I use another picture to
store the image
Savepicture Form2.Picture1.Picture "c:\save.bmp" 'I save the image to a
file

Thank you all very much and a special thank to Tm4321 (from
comp.lang.basic.visual.misc): I solved my
problem using the information he gave me.

Bye bye from Italy!

PS: forgive my english mistakes!

--
_______             __      ? GENERATORE AUTOMATICO MAPPE FRATTALI
|   __ \---.-.-----.  |-----. P R O G R A M M A -  F R E E W A R E
|    __/  _  |  _  |  |  _  | IN TOP 50 FREEWARE SU  www.zdnet.com
|___|   ___._|_____|__|_____| UTILIZZABILE CON Winfract & Fractint
|Nome:   Paolo Guagliumi    |



Sun, 28 Oct 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to save a new palette in a bmp file

2. How to Save VGA Palette to Disk File?

3. save bmp in same depth as loaded bmp

4. Saving API Drawings to a BMP or Converting from WMF to BMP

5. SAVE pcx/gif/bmp file?

6. VB3: Saving bitmap from datafield to .BMP file

7. saving text in BMP output file

8. How to Save .bmp file

9. Saving BMP file in VB5

10. (Q)Save current screen as bmp file to harddisk

11. Saving monochrome BMP-File

12. Save pictureboxes as a BMP file?

 

 
Powered by phpBB® Forum Software