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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:15:58+00:00 2026-05-25T17:15:58+00:00

I am trying to resize (scale) a bitmap image using a dll function which

  • 0

I am trying to resize (scale) a bitmap image using a dll function which is below mentioned

{ to resize the image }
function ResizeImg(maxWidth,maxHeight: integer;thumbnail : TBitmap): TBitmap;
var
 thumbRect : TRect;
begin
 thumbRect.Left := 0;
 thumbRect.Top := 0;

 if thumbnail.Width > maxWidth then
  begin
   thumbRect.Right := maxWidth;
  end
 else
  begin
    thumbRect.Right := thumbnail.Width;;
  end;

 if thumbnail.Height > maxHeight then
  begin
   thumbRect.Bottom := maxHeight;
  end
 else
  begin
   thumbRect.Bottom := thumbnail.Height;
  end;
 thumbnail.Canvas.StretchDraw(thumbRect, thumbnail) ;

  //resize image
 thumbnail.Width := thumbRect.Right;
 thumbnail.Height := thumbRect.Bottom;

 //display in a TImage control
 Result:= thumbnail;
end;

It works fine when I use this application call (to feed all the images in my listview):

  //bs:TStream; btmap:TBitmap;
  bs := CreateBlobstream(fieldbyname('Picture'),bmRead);
  bs.postion := 0;
  btmap.Loadfromstream(bs);
  ListView1.Items[i].ImageIndex := ImageList1.Add(ResizeImg(60,55,btmap), nil);

But when I try this application call (to get individual image into my TImage component):

 bs := CreateBlobstream(fieldbyname('Picture'),bmRead);
 bs.postion := 0;
 btmap.Loadfromstream(bs);
 Image1.Picture.Bitmap := ResizeImg(250,190,btmap);

It gives me an error on:

 thumbnail.Canvas.StretchDraw(thumbRect, thumbnail) ;

saying:

 AV at address 00350422 in module 'mydll.dll' Read of Address 20000027

And when I close my executable I get this:

 runtime error 216 at 0101C4BA 

If I define and use the same function (ResizeImg) inside my exe pas file it works completely fine without any errors.

  • 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-25T17:15:59+00:00Added an answer on May 25, 2026 at 5:15 pm

    You can’t pass Delphi objects between modules unless you take steps to ensure that those modules share the same runtime and memory allocator. Ir appears you have not taken such steps.

    The basic problem is that a Delphi object is both data and code. If you naively call a method on an object that was created in a different module then you execute code from this module on data from that module. That typically ends in runtime errors.

    You have at least the following options:

    1. Use runtime packages. This will enforce a shared runtime.
    2. Use COM interop. COM was designed for sharing components across module boundaries.
    3. Link all code into a single executable.
    4. Pass HBITMAPs between the modules since they can be shared in such a manner.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to resize the image using javascript, but I am getting errors
Basically I am inserting an image using the listviews inserting event, trying to resize
I am trying to resize an image before it gets saved. I am using
I'm trying to resize an image using stretchableImageWithLeftCapWidth: it works on the simulator, but
I am trying to resize an image using only CSS, the problem is I
I got a jpeg image in which is 1020x780, I am trying to resize
I have a function in which I'm trying to resize a photo twice from
I am trying to resize a bitmap using this... try { bitmap = BitmapFactory.decodeStream((InputStream)new
I'm trying to resize an image into a square thumbnail using ASP. The image
I'm trying to resize an image in Silverlight 3 that has been submitted by

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.