Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8728325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:36:49+00:00 2026-06-13T08:36:49+00:00

I thought instead of using TImage with an 8bit BMP I’d save my own

  • 0

I thought instead of using TImage with an 8bit BMP I’d save my own Bitmap – which I have done with Delphi a few times before. But for some reason I cannot figure out, the first two bytes of the file is always written as four bytes!
My record for the header is

type
 BitmapH = Record
  head : WORD;
  filesize : DWORD;
  reserved : DWORD;
  bmpoffset : DWORD;
  bmpheadersize : DWORD;
  width : DWORD;
  height : DWORD;
  planes : WORD;
  bpp : word;
  comp : longint;
  bmdatasize : longint;
  hres : longint;
  vres : longint;
  numofcolors : longint;
  importantcolors : longint;
  palette : array[0..1023] of byte;
 end;

I’ve tried even changing it to a 2 byte array still no go. Even with it changed to just head : byte; it still writes 1 byte then pushes junk to the next 3. I must be missing something simple!

Here’s how I am writing the file header –

var BM : file of BitmapH;
var BMD : file of byte;
var header : BitmapH;
var i : integer;
var test : byte;
begin

  AssignFile(BM, 'd:\test.bmp');
  Rewrite(BM);

  header.head := 19778;
//  header.head[1] := 'M';
  header.filesize := 2102;
  header.reserved := 0;
  header.bmpoffset := 1080;
  header.bmpheadersize := 40;
  header.width := 32;
  header.height := 32;
  header.planes := 1;
  header.bpp := 8;
  header.comp := 0;
  header.bmdatasize := 1024;
  header.hres := 100;
  header.vres := 100;
  header.numofcolors := 0;
  header.importantcolors := 0;

  for i := 0 to 255 do
  begin
    header.palette[i*4] := getBvalue(palette[i]);
    header.palette[(i*4) + 1] := getBvalue(palette[i]);
    header.palette[(i*4) + 2] := getBvalue(palette[i]);
    header.palette[(i*4) + 3] := 0;
  end;

  Write(BM, header);

Sorry for the crudeness, it’s just a test 🙂

Any help is appreciated!

PS – The reason for not using TImage to save is because I am changing the palette on the fly which seems like a hassle to edit via TImage.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:36:51+00:00Added an answer on June 13, 2026 at 8:36 am

    Use packed record to avoid the default memory alignment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have been having an issue sine using the HABTM relationship in models instead of
I was just doing some yicky code and I thought, instead of using three
I have to count the word frequency in a text using python. I thought
I thought I'd find more about this topic but I didn't. I have to
I have a site in ASP.NET and i thought it would be cool if
I want to hide parameters from URL. I'm using uuids instead of ids and
I using pre-existing code in matlab that is organized into classes. Instead of using
I am using EF4.3 with a unit-of-work + repository pattern. I have a method
I'm writing a small application for myself and instead of using a database I'd
I have built an Android chat application. It has a TCP server which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.