1. Win32Lib and Bitmaps
- Posted by Reverend Ferlin <ferlin at SANDW.NET> Nov 16, 1998
- 651 views
All, I am working on a program utilizing Win32Lib, however I am trying to include a bit map that uses some kind of palette other than the standard windows palette, how can I make the bit map display with the correct palette under exw and win32lib? Bellow is the code currently used in the program. global constant Logo = create( Bitmap, "", MainWin, a-4, a-4, 32*a, 32*a, 0 ) procedure onLoad_MainWin() setBitmap(Logo, "test.bmp") end procedure onLoad [ MainWin ] = routine_id( "onLoad_MainWin" ) TIA, + + + Rev. Ferlin Scarborough - Centreville, Alabama - USA
2. Re: Win32Lib and Bitmaps
- Posted by Irv Mullins <irv at ELLIJAY.COM> Nov 16, 1998
- 576 views
- Last edited Nov 17, 1998
On Mon, 16 Nov 1998 17:19:38 -0600, Reverend Ferlin <ferlin at SANDW.NET> wrote: >All, > > I am working on a program utilizing Win32Lib, however >I am trying to include a bit map that uses some kind of palette >other than the standard windows palette, how can I make the bit map >display with the correct palette under exw and win32lib? > > There's a way to adjust the palette programmatically - it's hard to understand. Here's the easy way: Write a short program that sets the proper graphic mode, and then saves the screen as a bitmap. Load the saved bitmap into PaintShopPro, and save the palette as "EU_STD" or some such. Load your picture you are going to use, and load the new EU_STD palette. Apply it to your pic, save it, and you're done. Try different dithering and such to get the best effect. Sometimes it helps to convert the picture to high color before loading the std bitmap, and then convert back down when saving as a bitmap. Regards, Irv
3. Re: Win32Lib and Bitmaps
- Posted by "Cuny, David" <David.Cuny at DSS.CA.GOV> Nov 16, 1998
- 578 views
Reverend Ferlin wrote: > I am working on a program utilizing Win32Lib, > however I am trying to include a bitmap that > uses some kind of palette other than the standard > windows palette, how can I make the bit map display > with the correct palette under exw and win32lib? I was under the impression that Win32 automatically converted the bitmap to the proper palette - there's supposed to be a createCompatibleBitmap or some such function in there. Pete has some assembly code for converting bitmaps from one palette to another for DOS on his home page, and I'll be including that function in Dos32Lib. I didn't expect that you would have to deal with that in Win32, though. -- David Cuny
4. Re: Win32Lib and Bitmaps
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Nov 17, 1998
- 612 views
>I was under the impression that Win32 automatically converted the bitmap to >the proper palette - there's supposed to be a createCompatibleBitmap or some >such function in there. Pete has some assembly code for converting bitmaps >from one palette to another for DOS on his home page, and I'll be including >that function in Dos32Lib. I didn't expect that you would have to deal with >that in Win32, though. Interestingly, Im not trying to annoy, David, im trying to make a point. If you would use Neil for dos32lib, it would create a compatible palette without any effort from you. Ralf
5. Re: Win32Lib and Bitmaps
- Posted by Reverend Ferlin <ferlin at SANDW.NET> Nov 19, 1998
- 578 views
A few days ago I wrote: > > All, > > I am working on a program utilizing Win32Lib, however > I am trying to include a bit map that uses some kind of palette > other than the standard windows palette, how can I make the bit map > display with the correct palette under exw and win32lib? Since then I have discovered that on my laptop at home this bitmap displays just fine, the differences in the two systems, is the laptop is set to High Color, and the Desktop is set to 256 Colors. The laptop is running Windows 95 and the Desktop is running Windows 98. In an additional note, when I bring the bitmap up in MSPAINT, or LVIEWPRO or KODAK IMAGING, it looks right on both systems, and all the above programs give the bitmap resolution as 792x5522x256. ANY suggestions as to what is happening here? + + + Rev. Ferlin Scarborough - Centreville, Alabama - USA
6. Re: Win32Lib and Bitmaps
- Posted by Reverend Ferlin <ferlin at SANDW.NET> Nov 19, 1998
- 595 views
> the above programs give the bitmap resolution as 792x5522x256. Oooops the above should read 792x522x256. + + + Rev. Ferlin Scarborough - Centreville, Alabama - USA
7. Re: Win32Lib and Bitmaps
- Posted by "Cuny, David" <David.Cuny at DSS.CA.GOV> Nov 19, 1998
- 605 views
Reverend Ferlin wrote: > I am working on a program utilizing Win32Lib, however > I am trying to include a bit map that uses some kind of palette > other than the standard windows palette, how can I make the bit map > display with the correct palette under exw and win32lib? Here is some code you might want to fool around with. It requires two bitmap files. "pName" is the name of a file with a "good" palette. "fName" is the name of the file to convert, which has a "bad" palette. The program reads the two bitmaps, and matches up the palettes as best it can. It then creates a new bitmap file called "new.bmp" which combines the image and new palatte. There are, of course, some catches. According to an article I'm plowing through, the comparison of the pallette values should be: sqrt( (r1-r2)^2 + (g1-g2)^2 + (g1-g2)^2 ) and not: abs( r1-r2 ) + abs( g1-g2 ) + abs( b1-b2 ) that I'm using. If you want to read the article, take a look at: It also explains that you really should grab the system palette, yada yada yada... This is left as an exercise to the gentle reader. Eventually, I'll get Win32Lib right, and it will *automatically* map the bitmap to the system palette. In the meantime, this is the best I can offer. -- David Cuny -- fixbmp.ex -- set a bitmap so the palette matches that -- of another bitmap -- this holds the name of a bitmap with a "good" palette constant fName = "palette.bmp" -- this holds the name of a bitmap with a "bad" palette constant pName = "image.bmp" include image.e ------------------------------------- function abs( atom a ) if a > 0 then return a else return -a end if end function ------------------------------------- function convertToPalette( sequence rgb, sequence pal ) -- convert the rgb tuple to an index to the best match in the -- palette integer err atom best, bestErr sequence colorIndex -- build holder for results colorIndex = repeat( 0, length( rgb ) ) -- set the last best match as impossibly bad best = 1 bestErr = #FFFF -- look through the palette for i = 1 to length( pal ) do -- error amount for this entry err = 0 -- for each {rgb} for j = 1 to 3 do -- error is difference between the two -- should really be: -- err + power( abs( pal[i][j] - rgb[j] ), 2 ) err = err + abs( pal[i][j] - rgb[j] ) end for -- if you did that "power" fix i suggested, then you need -- to do a -- err = sqrt( err ) -- down here. -- better match than prior best match? if err <= bestErr then -- save error amount bestErr = err -- save index best = i end if end for return best end function ------------------------------------- ------------------------------------- -- main section sequence bmpPal, bmpImage, myPal, myIndex object bmp, pal -- read the bitmap for the palatte pal = read_bitmap( pName ) if atom( pal ) then printf( 1, "Unable to open palette bitmap file %s\n", {pName} ) abort(0) end if -- read the bitmap bmp = read_bitmap( fName ) if atom( bmp ) then printf( 1, "Unable to open bitmap file %s\n", {fName} ) abort(0) end if -- discard the image data pal[2] = "" -- get the palettes myPal = pal[1] bmpPal = bmp[1] -- build lookup index myIndex = repeat( 0, length( bmpPal ) ) -- convert each element in the palette for i = 1 to length( bmpPal ) do -- get the closest match in the target palette myIndex[i] = convertToPalette( bmpPal[i], myPal ) end for -- get the bitmap image bmpImage = bmp[2] -- replace the bitmap references with the new palatte for i = 1 to length( bmpImage ) do for j = 1 to length( bmpImage[i] ) do -- replace each reference to the old palette -- with a reference to the new one bmpImage[i][j] = myIndex[ bmpImage[i][j]+1 ]-1 end for end for if save_bitmap( { myPal, bmpImage}, "new.bmp" ) then puts( 1, "Unable to write output file NEW.BMP\n" ) else puts( 1, "Created NEW.BMP\n" ) end if
8. Re: Win32Lib and Bitmaps
- Posted by Irv Mullins <irv at ELLIJAY.COM> Nov 20, 1998
- 615 views
On Thu, 19 Nov 1998 15:26:12 -0800, Cuny, David <David.Cuny at DSS.CA.GOV> wrote: Thanks! This info should be helpful. Irv