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 7950891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:24:17+00:00 2026-06-04T02:24:17+00:00

I am using Delphi7 with the KOL Components and JPegObj. How can I transfer

  • 0

I am using Delphi7 with the KOL Components and JPegObj.
How can I transfer a PBitmap to PJpeg?

var 
 MyBitmap : PBitMap;
 MyJpeg   : PJpeg;
begin
 MyBitMap := ....;
 MyJPeg.Bitmap.Assign (MyBitMap); // ===> Wrong?
 MyJPeg.SaveToFile ('C:\test.jpg');
end;

Thanks for your help.

EDIT: Picture here:

enter image description here

EDIT: My Code:

program Project2;

{$APPTYPE CONSOLE}

uses
 Kol,
 JpegObj;

var
 Jpeg: PJpeg;
 Bitmap: PBitmap;

begin
 Bitmap := NewBitmap(50, 50);
 try
  Bitmap.Canvas.Brush.Color := $0000FF80;
  Bitmap.Canvas.Ellipse(0, 0, 50, 50);
  Jpeg := NewJpeg;
  try
   Jpeg.Bitmap := Bitmap;
   Jpeg.SaveToFile('test.jpg');
  finally
   Jpeg.Free;
  end;
 finally
 Bitmap.Free;
end;

Runtime Error 216 at 0041128E

EDIT:
I uncommented the line in JpegObj:

 {$DEFINE VER62} // if you plan to use .obj-files from Delphi7 distributive only!

Now the program is just frozen.

EDIT: The program freezes here in JpegObj

function __ftol: Integer;
 var
  f: double;
begin
 asm
  lea    eax, f             //  BC++ passes floats on the FPU stack
  fstp  qword ptr [eax]     //  Delphi passes floats on the CPU stack
 end;
 Result := Integer(Trunc(f));
end;
  • 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-04T02:24:19+00:00Added an answer on June 4, 2026 at 2:24 am

    Disclaimer: The following has been tested on Delphi 2009!

    You cannot use PJpeg.Bitmap.Assign on your PJpeg instance because the PJpeg.Bitmap is nil at the time you are accessing it since it’s not instantiated in PJpeg constructor nor later while you were working with that instance. So the attempt to work with the PJpeg.Bitmap leads to an access violation.

    Try to assign the bitmap this way (it’s based on the example from the JpegObj extension):

    var 
      MyJpeg: PJpeg;
      MyBitmap: PBitmap;
    begin
      // the MyBitMap has a picture assigned here
      MyJpeg := NewJpeg;
      try
        MyJpeg.Bitmap := MyBitmap;
        MyJpeg.SaveToFile('c:\test.jpg');
      finally
        MyJpeg.Free;
      end;
    end;
    

    Here is a VCL minimalistic demo:

    uses
      KOL, JPEGObj;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      Jpeg: PJpeg;
      Bitmap: PBitmap;
    begin
      Bitmap := NewBitmap(50, 50);
      try
        Bitmap.Canvas.Brush.Color := $0000FF80;
        Bitmap.Canvas.Ellipse(0, 0, 50, 50);
        Jpeg := NewJpeg;
        try
          Jpeg.Bitmap := Bitmap;
          Jpeg.SaveToFile('c:\image.jpg');
        finally
          Jpeg.Free;
        end;
      finally
        Bitmap.Free;
      end;
    end;
    

    And the amazing result 🙂

    enter image description here

    Here is another, console minimalistic demo:

    program Console;
    
    {$APPTYPE CONSOLE}
    
    uses
      SysUtils, KOL, JPEGObj;
    
    var
      Jpeg: PJpeg;
      Bitmap: PBitmap;    
    begin
      try
        Bitmap := NewBitmap(50, 50);
        try
          Bitmap.Canvas.Brush.Color := $0000CCFF;
          Bitmap.Canvas.Ellipse(0, 0, 50, 50);
          Jpeg := NewJpeg;
          try
            Jpeg.Bitmap := Bitmap;
            Jpeg.SaveToFile('c:\image.jpg');
          finally
            Jpeg.Free;
          end;
        finally
          Bitmap.Free;
        end;
      except
        on E:Exception do
          Writeln(E.Classname, ': ', E.Message);
      end;
    end.
    

    And the exciting result 🙂

    enter image description here

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

Sidebar

Related Questions

I'm using Delphi7 (non-unicode VCL), I need to store lots of WideStrings inside a
i am using delphi7/2009. how to determine the content of Tpicture? jpeg bmp png
Using Delphi 2007 I can write the following code: interface TTestType = (ttTest1, ttTest2);
By using Delphi 5, can I call a function in web service which is
Using Delphi 2010. I am looking for (possibly) a function or procedure which can
I am using Delphi version 5.0 and i have installed the DOA components for
I'm using Delphi7 and I'd like to bold some days of a TDateTimePicker control.
I am using Delphi 7 and ICS components to communicate with php script and
I'm using Delphi7 under Windows XP. How would I go about adding a Delete
Using Delphi 2007 and TMS components for Unicode utils and interface (upgrading to Delphi

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.