Giter VIP home page Giter VIP logo

Comments (12)

davidmz avatar davidmz commented on August 29, 2024 4

Ok, you should not set the width/height of canvas other than width/height of image. Frames renders in 1:1 scale so it's natural that if you change that, the picture will be cropped. But the width/height attributes don't determine rigidly the physical dimensions of element. You can set any size for canvas by CSS, regardless of the width and height attributes values.

from apng-js.

davidmz avatar davidmz commented on August 29, 2024 2

I just opened the demo page, added a canvas { width: 300px; } style via Chrome inspector and loaded APNG file. The file was animated normally and the width of the element on the page was 300px. So it works the way it should.
image

from apng-js.

davidmz avatar davidmz commented on August 29, 2024

You can use a regular CSS width/height to contol size of canvas element.

from apng-js.

sainyanhtay avatar sainyanhtay commented on August 29, 2024

Yes. It can't show the image when reducing the canvas element. Because the image which parsed APNG image size from canvas still remains the original size.

from apng-js.

sainyanhtay avatar sainyanhtay commented on August 29, 2024

I think It needs to control since parseAPNG(buffer) method was called. But, I don't know how to control the size of the parsed image dynamically for each image in your method. How can I do for that, @davidmz . Thanks

from apng-js.

davidmz avatar davidmz commented on August 29, 2024

I'm afraid I don't understand your problem. This library does not create canvas elements. You can create canvas yourself, assign it the right size via CSS, and start playing APNG in it.

It may be easier if you show the problem code on codesandbox, for example.

from apng-js.

sainyanhtay avatar sainyanhtay commented on August 29, 2024

I was testing in your demo project.

-I have the image(APNG) to upload , width : 1920px, height: 1080px
-But for example : I want to show that image only width 300px , height 300px
-So I change css style of apng-ani div and canvas element , then the image can't show.

from apng-js.

sainyanhtay avatar sainyanhtay commented on August 29, 2024

Annotation 2019-11-25 012441

I changed only width 300px from the original 480px. Then, It does not show the entire image. You can check the image by https://apng.onevcat.com/assets/elephant.png

from apng-js.

davidmz avatar davidmz commented on August 29, 2024

Please send a link to a live demonstration of the problem.

from apng-js.

championboylay avatar championboylay commented on August 29, 2024

Hi davidmz, could you see https://estates-officer-elephant-63118.netlify.com/ for resizing issue. I made
canvas.width = 300;
canvas.height = 400;

from apng-js.

championboylay avatar championboylay commented on August 29, 2024

OMG! It work like a charm 👍

from apng-js.

sainyanhtay avatar sainyanhtay commented on August 29, 2024

Thanks @davidmz . It works for me.

from apng-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.