473,322 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Loading an image with no palette...

I've been ripping my hair our trying to get this to work for a week and I can't seem to get it. I'm trying to display a 4BppIndexed Bitmap from within the ntoskrnl.exe file that contains no palette. This bitmap is the one everyone likes to change to customize their boot screen. My goal is not to edit the kernel, but simply to display the bitmap content in much the same way a resource editor does.

My problem is that no matter what I do, the image always comes out completely black. Here's the code I'm using below, I hope SOMEONE can help me...

Thank you,
Jean-Sebastien Carle

-----------------------------------------------------------

// Get the module handle.
IntPtr hModule = Win32API.Kernel32.LoadLibrary(@"C:\Windows\System3 2\ntoskrnl.exe");

// Get the bitmap handle.
IntPtr hBMP = Win32API.User32.LoadImage(hModule, 1, Win32API.User32.IMAGE_BITMAP, 0, 0, Win32API.User32.LR_CREATEDIBSECTION);

// Release the module handle.
Win32API.Kernel32.FreeLibrary(hModule);

// Create default 16 color palette.
Win32API.GDI32.LOGPALETTE logPal;
logPal.palVersion = 0x300;
logPal.palNumEntries = 16;
logPal.palPalEntry = new byte[64];
logPal.palPalEntry[0] = 0;
logPal.palPalEntry[1] = 0;
logPal.palPalEntry[2] = 0;
logPal.palPalEntry[3] = 0;
logPal.palPalEntry[4] = 0;
logPal.palPalEntry[5] = 0;
logPal.palPalEntry[6] = 0;
logPal.palPalEntry[7] = 0;
logPal.palPalEntry[8] = 32;
logPal.palPalEntry[9] = 26;
logPal.palPalEntry[10] = 21;
logPal.palPalEntry[11] = 0;
logPal.palPalEntry[12] = 45;
logPal.palPalEntry[13] = 62;
logPal.palPalEntry[14] = 210;
logPal.palPalEntry[15] = 0;
logPal.palPalEntry[16] = 83;
logPal.palPalEntry[17] = 101;
logPal.palPalEntry[18] = 1;
logPal.palPalEntry[19] = 0;
logPal.palPalEntry[20] = 178;
logPal.palPalEntry[21] = 53;
logPal.palPalEntry[22] = 5;
logPal.palPalEntry[23] = 0;
logPal.palPalEntry[24] = 70;
logPal.palPalEntry[25] = 70;
logPal.palPalEntry[26] = 70;
logPal.palPalEntry[27] = 0;
logPal.palPalEntry[28] = 137;
logPal.palPalEntry[29] = 146;
logPal.palPalEntry[30] = 0;
logPal.palPalEntry[31] = 0;
logPal.palPalEntry[32] = 74;
logPal.palPalEntry[33] = 127;
logPal.palPalEntry[34] = 252;
logPal.palPalEntry[35] = 0;
logPal.palPalEntry[36] = 247;
logPal.palPalEntry[37] = 107;
logPal.palPalEntry[38] = 32;
logPal.palPalEntry[39] = 0;
logPal.palPalEntry[40] = 141;
logPal.palPalEntry[41] = 166;
logPal.palPalEntry[42] = 255;
logPal.palPalEntry[43] = 0;
logPal.palPalEntry[44] = 142;
logPal.palPalEntry[45] = 220;
logPal.palPalEntry[46] = 4;
logPal.palPalEntry[47] = 0;
logPal.palPalEntry[48] = 243;
logPal.palPalEntry[49] = 188;
logPal.palPalEntry[50] = 27;
logPal.palPalEntry[51] = 0;
logPal.palPalEntry[52] = 188;
logPal.palPalEntry[53] = 188;
logPal.palPalEntry[54] = 188;
logPal.palPalEntry[55] = 0;
logPal.palPalEntry[56] = 255;
logPal.palPalEntry[57] = 255;
logPal.palPalEntry[58] = 255;
logPal.palPalEntry[59] = 0;
logPal.palPalEntry[60] = 255;
logPal.palPalEntry[61] = 255;
logPal.palPalEntry[62] = 255;
logPal.palPalEntry[63] = 0;

// Assign logical palette.
IntPtr hPalette = Win32API.GDI32.CreatePalette(ref logPal);

// Create bitmap with specified palette.
Bitmap bmp1 = new Bitmap(Image.FromHbitmap(hBMP, hPalette), Image.FromHbitmap(hBMP).Width, Image.FromHbitmap(hBMP).Height);

Nov 16 '05 #1
0 1783

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alex Hunsley | last post by:
I'm using python image library 1.1.4 (http://www.pythonware.com/products/pil/) to plot images. However, when I save an image to a gif file, it comes out very dotty/ithered looking, even if it's a...
0
by: jean marc | last post by:
Hello I am trying to reduce a truecolor image to a palette one. imagetruecolortopalette() works just fine, except, that I would like to keep a few color unchanged. like a (255,0,0) red, a...
1
by: Jeff Stewart | last post by:
Is there a procedure for determining whether or not an Image uses any of the indexed pixel formats, short of checking against each one? -- Jeff S.
0
by: bearophileHUGS | last post by:
Hello, this time I have a question about PIL usage, maybe if Lundh has some time he can answer me. I am experimenting different color quantization algorithms, so having computed the palette with a...
5
by: Neeraj | last post by:
hi I am working on dicom viewer. 8 bit raw dicom image working properly.But 16 bit Dicom image is not showing.What Should i have to do.You have any idea about That to convert it in 8bit ....
0
by: Matteo | last post by:
Hi, i sent image byte via bt from j2me phone to c# application, after i have to create image using this code: .... byte pixels .... Bitmap bmp = new Bitmap(160, 120,...
0
by: skip | last post by:
I'm unclear how PIL handles multi-frame GIF images. I have such a GIF image in a file, bogus.gif. I can view the individual frames like so (ImageSequence is from the PIL tutorial): ... ...
4
by: Dale | last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web app and rendering them by using System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF). I am confident that...
8
by: JJ | last post by:
Whilst I am resizing images I am losing quality. This is only happening in small amounts, but if you repeatedly put the same image through the following code, the image quality slowly degrades. Can...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.