Jump to content

WebSite ScreenShot [Urgente]


pbreda
 Share

Recommended Posts

Boas, antes de mais sugiro que não uses tags do género "urgente", porque além de não ir de encontro ao que diz nas regras do fórum, não vai ajudar na resolução.

Quanto à dúvida, pensa bem: se tu queres ter uma representação gráfica da página, ela tem que ser mostrada nalgum lado, ou seja, fazer parsing ao HTML e mostrá-la graficamente ao utilizador. Logo, sem browser não vais lá. Mas se os websites forem bem conhecidos, podes sempre optar por serviços que te permitem devolver um screenshot da página.

Para obter a imagem, vais buscar o endereço da mesma, usando a técnica que usaste para buscar da metatags (outro tópico), fazes download dela e mostras para o utilizador da forma que pretendes.

Google > website screenshot

Nick antigo: softclean | Tens um projeto? | Wiki P@P

Ajuda a comunidade! Se encontrares algo de errado, usa a opção "Denunciar" por baixo de cada post.

Link to comment
Share on other sites

Eu tenho um exemplo em C# e é como tas a dizer eu tentei transpor mas tem bugs o código C# é o seguinte:

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Windows.Forms;
      using System.Drawing.Imaging;
      using System.Drawing.Drawing2D;
      using System.IO;
      using System.Runtime.InteropServices;
  
      namespace ScreenshotTaker
        {
            public partial class Form1 : Form
          {
              public Form1()
              {
                  InitializeComponent();
              }

              private void btnLoad_Click(object sender, EventArgs e)
              {
                  webBrowser1.Navigate("http://www.geekpedia.com");
              }

              private void btnSnap_Click(object sender, EventArgs e)
              {
                   // The size of the browser window when we want to take the screenshot (and the size of the resulting bitmap)

                  Bitmap bitmap = new Bitmap(1024, 768);
                  Rectangle bitmapRect = new Rectangle(0, 0, 1024, 768);

                  // This is a method of the WebBrowser control, and the most important part
                  webBrowser1.DrawToBitmap(bitmap, bitmapRect);

                  // Generate a thumbnail of the screenshot (optional)
                   System.Drawing.Image origImage = bitmap;
                   System.Drawing.Image origThumbnail = new Bitmap(120, 90, origImage.PixelFormat);
  
                  Graphics oGraphic = Graphics.FromImage(origThumbnail);
                  oGraphic.CompositingQuality = CompositingQuality.HighQuality;
                  oGraphic.SmoothingMode = SmoothingMode.HighQuality;
                  oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
                  Rectangle oRectangle = new Rectangle(0, 0, 120, 90);
                  oGraphic.DrawImage(origImage, oRectangle);

                  // Save the file in PNG format
                  origThumbnail.Save("Screenshot.png", ImageFormat.Png);
                  origImage.Dispose();
              }
          }
      }

Qualquer coisa esfrega a lampada!!!Visite Banco de Software e desfrute do software disponível xD

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.