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

  • SEARCH
  • Home
  • 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 7078981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:36:52+00:00 2026-05-28T06:36:52+00:00

I have been around the world twice and a half trying to fix a

  • 0

I have been around the world twice and a half trying to fix a strange issue with a large sum of images I have.

What I need is to know how to read and write the first 4 and 18th bytes in the header of a JPEG file. If they match certain properties, I need to do some certain work and tweak these bytes to reflect something else. I’m basically fixing the format of these pictures to a more standard format, as Delphi doesn’t recognize the format they’re in.

So how do I read/write these bytes? What do I use? I know nothing about reading the raw data of an image file, let alone tweaking it.


NOTE

Deleted most of the question as I had put way too much information from the start.

  • 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-05-28T06:36:53+00:00Added an answer on May 28, 2026 at 6:36 am

    The mechanics of actually changing the JPG header are very easy. That doesn’t mean fixing the JPG is easy, it’s just that if you know what to change, you can easily do it. Since that’s what you’re asking, here’s how to change the JPG header in-memory, load the modified JPG into a TJpgImage and convert to TBitmap.

    Please note I don’t think this is a good approach. Fixing the resulting bitmap is so much easier! See my fresh answer to your other question for how to fix the bitmap here.

    And here’s the code you asked for (how to change the JPG header):

    function LoadJpegIntoBitmap_HeaderFix(const FileName:string): TBitmap;
    var M: TMemoryStream;
        P: PByteArray;
        Jpg: TJPEGImage;
    begin
      M := TMemoryStream.Create;
      try
        M.LoadFromFile(FileName);
        if M.Size < 18 then raise Exception.Create('File too short.');
        P := M.Memory;
    
        // Here you can manipulate the header of the JPG file any way you want.
        if P[0] = $07 then P[3] := P[17] - P[0]*3;
    
        // Now load the modified JPG into a TJpgImage
        Jpg := TJPEGImage.Create;
        try
          Jpg.LoadFromStream(M);
    
          // Convert to bitmap
          Result := TBitmap.Create;
          Result.Assign(Jpg);
    
        finally Jpg.Free;
        end;
    
      finally M.Free;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been playing around with Google Apps Script today and I am trying
I admit regex is a strange world and I have not been able to
I have been researching around trying to find the best way to begin developing
I have been dancing around this issue for awhile but it keeps coming up.
I have been looking around for a visualization framework that would aid graph visualization
I have been around browsing tutorials for android power button mods, I have a
I have been fiddling around with server side interceptors on CXF. But is seems
I have been running around here and there on NoSQL big data storage technologies.
I have been looking around for solutions, and tried to implement what is often
I have been playing around a bit with a fairly simple, home-made search engine,

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.