ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Clock Flip process
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

ickkm

13 Posts

Posted - Oct 12 2022 :  21:10:10  Show Profile  Reply
// Prepare
 ImageTrackBar.Position := 0;
 SourceImage.Bitmap.Assign(SecondImage2.Bitmap);
 SourceImage.Update;
 SecondImage2.IO.LoadFromFileAuto(DataDir[Ord(ETC) - $30]+ InttoStr(PicNum1)+'.png');
 SecondImage2.lockPaint;
 Inc(PicNum1);
 if PicNum1 = 10 then PicNum1 := 0;
 TargetImage.Bitmap.Assign(SecondImage2.Bitmap);
 TargetImage.Update;
 SecondImage2.UnlockPaint;
 CurrentImage.Bitmap.Assign(SourceImage.Bitmap);

  THeight := 103;
  Twidth  := 60;

  if fCurrentViewLines <> nil then
    freemem(fCurrentViewLines);
  getmem(fCurrentViewLines, sizeof(pointer) * THeight);
  for q := 0 to THeight - 1 do
  begin
   fCurrentViewLines[q] := CurrentImage.Bitmap.Scanline[q];
  end;
//================


procedure TfmMain.ClockFlipeffect(Step:Integer);
var
  W, H, Y: Integer;
begin
  W := CurrentImage.Width;
  H := CurrentImage.Height;

  if (Step = 0) then
    StretchBlt(CurrentImage.Bitmap.Canvas.Handle, 0, 0, W, H,
               SourceImage.Bitmap.Canvas.Handle, 0, 0, W, H,
               SRCCOPY);

  if Step = 0 then
    exit;


  SetStretchBltMode(CurrentImage.bitmap.Canvas.Handle, HALFTONE);

  CurrentImage.bitmap.Canvas.Pen.Color := clBlack;
  CurrentImage.bitmap.Canvas.Pen.Width := 1;
  CurrentImage.bitmap.Canvas.Pen.Style := psSolid;

    StretchBlt(CurrentImage.bitmap.Canvas.Handle, 0, 0, W, H div 2,
               TargetImage.Bitmap.Canvas.Handle, 0, 0, W, H div 2,
               SRCCOPY);
    if Step <= 512 then
    begin
      Y := MulDiv(H, Step, 1024);
      if IEGlobalSettings().TransitionsDrawAlternative = False then
      StretchBlt(CurrentImage.bitmap.Canvas.Handle, 0, H div 2, W ,H,
                 SourceImage.Bitmap.Canvas.Handle, 0, H div 2, W, H,
                 SRCCOPY);
      StretchBlt(CurrentImage.bitmap.Canvas.Handle, 0, Y, W , H div 2 - Y,
                 SourceImage.Bitmap.Canvas.Handle, 0, 0, W, H div 2,
                 SRCCOPY);

      if IEGlobalSettings().TransitionsDrawAlternative = False then
        PageFlipDarkenEdges(Y, Step);
    end
    else
    begin
      Y := MulDiv(H, Step - 512, 512) div 2;

      if IEGlobalSettings().TransitionsDrawAlternative = False then
        StretchBlt(CurrentImage.bitmap.Canvas.Handle, 0, H div 2, W, H div 2,
                   SourceImage.Bitmap.Canvas.Handle, 0, h div 2, W, H Div 2,
                   SRCCOPY);
      StretchBlt(CurrentImage.bitmap.Canvas.Handle, 0, H div 2, W, Y,
                 TargetImage.Bitmap.Canvas.Handle, 0, H Div 2, W, H div 2,
                 SRCCOPY);

      if IEGlobalSettings().TransitionsDrawAlternative = False then
        PageFlipDarkenEdges(H div 2 + Y, Step);
    end;
 CurrentImage.Update;
end;

procedure TfmMain.PageFlipDarkenEdges(iCurrentPosition, Step : Integer);
const
  Initial_Darken_Level = 0.23;
  Darkness_Reduction = 0.68;
var
  iX, iY: integer;
  ppx: pRGB;
  rr, gg, bb: integer;
  iFadeStep1 , iFadeStep2 : integer;
  bDoDarken: Boolean;
begin
  // Upper Flip
  iFadeStep1 :=  Round(Step + Round(1024 * 0.9) / 5.0);
  if iFadeStep1 > 1024 then iFadeStep1 := 1024;
  // Down Flip
  iFadeStep2 :=  Round(1024 - Step + Round(1024 * 0.9) / 5.0);
  if iFadeStep2 > 1024 then iFadeStep2 := 1024;

  for  iY := 0 to THeight - 1 do
  begin
     ppx := fCurrentViewLines[iY];
    for iX := 0 to TWidth - 1 do
    begin
      bDoDarken := iY > iCurrentPosition;
      if bDoDarken then
      begin
       // Upper Flip
       if iY < ((THeight-1) Div 2) then
       begin
        with ppx^ do
        begin
          r := (ppx^.r * (1024-iFadeStep1) ) shr 10;
          g := (ppx^.g * (1024-iFadeStep1) ) shr 10;
          b := (ppx^.b * (1024-iFadeStep1) ) shr 10;
        end;
       end
       // Down Flip
       else
       begin
        with ppx^ do
        begin
          r := (ppx^.r * iFadeStep2 ) shr 10;
          g := (ppx^.g * iFadeStep2 ) shr 10;
          b := (ppx^.b * iFadeStep2 ) shr 10;
        end;
       end;
       inc(ppx);
      end;
    end;
  end;
  CurrentImage.bitmap.Canvas.MoveTo(0, iCurrentPosition);
  CurrentImage.bitmap.Canvas.LineTo(TWidth, iCurrentPosition);
end;





I tried changing the page flip as Nigel said.
seems to be working fine
Please see the source to see if there is a better way.
Thanks to Nigel for the advice.

xequte

38608 Posts

Posted - Oct 13 2022 :  00:24:04  Show Profile  Reply
Nice work. You should upload a demo so I can play with it.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ickkm

13 Posts

Posted - Oct 14 2022 :  03:45:08  Show Profile  Reply


attach/ickkm/2022101434135_FilpTest.zip
7955.83 KB

Dear Nigel,
Compress the sample program and upload it.
This is the code I worked on in XE10.
Please understand even if the inside of the code is messy.
Please understand that the capacity is a bit large for uploading as shown in the sample picture.
I think it would be better if it was included in the transition effect in the future.
Go to Top of Page

xequte

38608 Posts

Posted - Oct 16 2022 :  20:48:10  Show Profile  Reply
Wow, that effect looks really good. Nice work.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ickkm

13 Posts

Posted - Oct 18 2022 :  02:47:31  Show Profile  Reply


attach/ickkm/2022101823135_filpTimer.zip
7881.25 KB

I tried to link it with the watch.
Please take a look at this and let me know if you have any better ideas.
Go to Top of Page

xequte

38608 Posts

Posted - Oct 18 2022 :  17:37:17  Show Profile  Reply
Nice work. It looks very realistic.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: