How can i enlarge an image with graphic codes in TP7? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How can i enlarge an image with graphic codes in TP7?

ZirtikZirtik Posts: 1Member
Hi;
I want to enlarge an image which is determined with the coordinates {(x1,y1),(x2,y1),(x1,y2),(x2,y2)} with a specific ratio. For example a want to dubble size an image.
İf i can do this i will easily stretch an image in pascal.
Thanks for yor attention...

Comments

  • zibadianzibadian Posts: 6,349Member
    : Hi;
    : I want to enlarge an image which is determined with the coordinates {(x1,y1),(x2,y1),(x1,y2),(x2,y2)} with a specific ratio. For example a want to dubble size an image.
    : İf i can do this i will easily stretch an image in pascal.
    : Thanks for yor attention...
    :
    That's quite easy. Instead of placing 1 pixel on the screen, place 2x2 (or more for larger zoom ratios) pixels on the screen. Here is a little pseudo code, which performs this.
    [code]
    procedure DrawPicture(
    Image:array[1..30,1..30] of byte; { Image map }
    ZoomFactor:byte; { zoom factor }
    OriginX,OriginY:integer); {top-left corner}
    var
    x,y,i,j:integer;
    begin
    for x:=0 to 29 do
    for y:=0 to 29 do
    for i:=0 to ZoomFactor-1 do
    for j:=0 to ZoomFactor-1 do
    SetPixel( {SetPixel doesn't exists, I think; but there is a procedure in the Graph unit, which allows you to set 1 pixel}
    OriginX+X*ZoomFactor+i, { Column position of pixel }
    OriginY+Y*ZoomFactor+i, { Row position of pixel }
    Image[X+1,Y+1]); { Pixel }
    end;
    [/code]
    This code is quite slow and untested. The position formulas are correct, but I don't remember the name of the correct procedure (too much Delphi & too little pascal).

    Good luck
Sign In or Register to comment.