Silverlight + Deep Zoom = RIA Experiences Parte 2 – Deep Zoom Dinamico – YES WE CAN

By rdorta at setembro 14, 2009 12:11
Filed Under: Silverlight

No meu post anterior, Silverlight + DeepZoom = RIA Experiences Parte 1 - Utilizando o Deep Zoom Composer, mostrei como podemos criar experiências simples com o Deep Zoom Composer.

Uma das grandes reclamações que eu costumo ouvir sobre o deep zoom é que não conseguimos criar experiências onde os dados sejam dinamicos, e a obrigatoriedade de utilizar o Deep Zoom Composer.

Esse meu post é dedicado a acabar com essa “crença”. Deep Zoom dinamico? YES WE CAN!!!

Criando o projeto

Para começar vamos precisar das seguintes ferramentas:

Siverlight 2 + Tools (também funciona com o 3, só estou usando o 2 porque estou finalizando um projeto que começou com ele)

Um pouco de conhecimento sobre imagens e tratamento de imagens com C# (google it!!!)

Deep Zoom Composer ( Leitor diz: nããããããõ!!!!…. Dorta diz: Calma!! é só pra pegar uma dll!!!!)

DeepZoomTools.dll

Bom, pra começar, vamos falar dessa dll. Você não vai achar praticamente nenhuma documentação sobre essa dll.

Ela foi criada pela própria equipe do Expression e foi divulgada nesse post do blog deles. Essa dll foi divulgada para que os desenvolvedores pudessem simular o funcionamento do Deep Zoom Composer em suas aplicações.

Abaixo segue os objetos que vamos utilizar e sua função:

ImageCreator: É o objeto de imagem utilizado pelo Deep Zoom.
CollectionCreator: Objeto responsável por criar aquelas diversas imagens para cada nível de zoom do nosso Deep Zoom

O que eu preciso saber de Deep Zoom?

Você deve ter conhecimento de como o Deep Zoom Composer trabalha, sugiro seguir meu post anterior Silverlight + DeepZoom = RIA Experiences Parte 1 - Utilizando o Deep Zoom Composer e criar algumas aplicações estáticas para entender alguns conceitos como:

Ao criar uma composição de Deep Zoom, são gerados inúmeros arquivos, com imagens e xmls que definem o comportamento de zoom da composição. (Pasta GeneratedImages)

Os xmls que são gerados definem os caminhos das imagens que serão utilizadas a cada nível de zoom

Vamos ao que interessa.

Crie um projeto do tipo Silverlight Application no VS 2008 e Peça para que seja criada uma aplicação WEB de testes. (Arquitetura em Siverlight vai dar um excelente post em breve).

image

Adiciona a sua pasta ClientBin do projeto WEB uma pasta chamada Generated Images

Adicione ao seu projeto WEB uma referencia a dll do DeepZoomTools : [Program Files]\Microsoft Expression\Deep Zoom Composer\DeepZoomTools.dll

O serviço que cria as imagens e xmls

Adicione ao seu projeto web, na pasta ClientBin, um Generic Handler, vamos chama-lo de ImageHandler:

image

 

Nosso serviço, vai ler as imagens de uma pasta (poderia ler qualquer imagem) e utiliza-las para montar um composição deep zoom.

O código que utilizei para buscar as imagens é bem simples:

private static List<string> ObterImagensDiretorio(DirectoryInfo pdiInformacaoDiretorio)
        {
            List<string> lstImagens = new List<string>();
            foreach (var finInformacaoImagem in pdiInformacaoDiretorio.GetFiles("*.jpg"))
            {
                lstImagens.Add(finInformacaoImagem.FullName);
            }
            return lstImagens;
        }

Agora no método ProcessRequest do nosso serviço, vamos inicializar as nossas variáveis:

1)Caminho para onde serão enviadas as imagens e XMLs

string strCaminhoImagensGeradas = context.Server.MapPath("~/ClientBin/GeneratedImages/");

2) Imagens que serão utilizadas no DeepZoom

           List<string> lstImagens = ObterImagensDiretorio(new DirectoryInfo(context.Server.MapPath("~/Imagem/")));

3) Lista de XMLs que serão gerados

          List<string> lstXMLs = new List<string>();

Por fim, mas não menos importante, criamos os objetos de imagem do Deep Zoom e a coleção:

O objeto ImageCreator e o objeto CollectionCreator possuem propriedades muito parecidas entre as quais podemos destacar:

TileSize – O tamanho que cada “tira” da composição deve assumir
TileFormat – O formato de arquivo de  cada “tira” (PNG, JPG, etc…)
ImageQuality – Como qualquer bom editor de imagem, você pode editar qual a qualidade de exportação da imagem, sendo 1 = 100%.

Ambos os objetos também possuem o método create:

ImageCreator.Create([Caminho original da imagem], [Caminho onde a imagem deve ser criada]);  - Cria as imagens e xmls referentes as imagens
ColectionCreator.Create([Lista dos caminhos dos xmls que contém as informações das imagens], [Caminho onde ele deve gerar a coleção completa]); Cria a estrutura completa de XML e imagens da composição

Segue o código abaixo:

foreach (string strImagem in lstImagens)
            {

                ImageCreator ic = new ImageCreator();

                ic.TileSize = 256;

                ic.TileFormat = ImageFormat.Jpg;

                ic.ImageQuality = 1;

                string target = strCaminhoImagensGeradas + "output_images\\" + Path.GetFileNameWithoutExtension(strImagem);

                ic.Create(strImagem, target);

                lstXMLs.Add(Path.ChangeExtension(target, ".xml"));

            }

            cc.TileSize = 256;

            cc.TileFormat = ImageFormat.Jpg;

            cc.MaxLevel = 8;

            cc.ImageQuality = 1;

            cc.Create(lstXMLs, strCaminhoImagensGeradas + "output");

WELL DONE!!! NOSSO SERVIÇO ESTA PRONTO!!! Agora vamos ao Silverlight:

DE VOLTA AO SILVERLIGHT

Agora vamos criar o DeepZoom utilizando o MultiScaleImage, no Silverlight.

Dentro dos seu LayoutRoot na sua Page.xaml crie os seguintes componentes:

<MultiScaleImage x:Name="msi" Height="Auto" Width="589"/>
        <Button Content="Embaralhar" HorizontalAlignment="Center" VerticalAlignment="Top" Click="Button_Click"/>

E agora no código Page.xaml.cs no método construtor, vamos invocar nosso serviço de geração de imagens:

WebClient wbc = new WebClient();
            wbc.OpenReadAsync(new Uri(“
http://localhost:3585/ClientBin/ImageHandler.ashx”));
            wbc.OpenReadCompleted += new OpenReadCompletedEventHandler(wbc_OpenReadCompleted);

E ao terminar o serviço vamos popular o nosso MultiScaleImage:

this.msi.Source = new DeepZoomImageTileSource(new Uri("http://localhost:3585/ClientBin/GeneratedImages/output.xml"));

DONE!!!

Espero que essas dicas ajudem a iluminar os passos para nova experiências com Silverlight e Deep Zoom.

Aqui está o link para o código fonte com imagens, um evento para capturar Mouse Wheel muito bom e um efeito de embaralhamento randomico nota 100000:

DeepZoomDinamico.zip (13,36 mb)

Nos vemos na próxima Arqinovação!!!

Comentários

16/9/2009 23:23:42 #

Márcio

Perfeito, muito bom mesmo, parabéns!

Márcio Brazil | Reply

20/11/2009 14:04:51 #

yo

muy bueno gracias, una pregunta, es posible generar varias colecciones dinamicas en un mismo proyecto?
Estoy intando pero no veo la manera.


yo Spain | Reply

7/7/2010 15:22:23 #

loans

Cars and houses are not very cheap and not every person can buy it. Nevertheless, home loans are created to support people in such kind of hard situations.

loans Canada | Reply

22/7/2010 6:48:02 #

thesis writing

It’s a imazing outcome related to study. Some students would like to have such perfect writing abilities. But they must purchase the thesis research recommended by some distinguished thesis.

thesis writing Canada | Reply

23/7/2010 18:46:14 #

dissertation

It is great that you make such hot outcome related to this good post. And I think that this can be good if students order the thesis help or buy dissertation with you help.

dissertation Canada | Reply

23/7/2010 22:47:16 #

injury lawyer

hi there, i just found your site on yahoo, and i would like to say that you write interestingly well via your web portal. i am truly impressed by the method that you write, and the subject is excellent. in any case, i would also like to acknowledge whether you would like to exchange links with my blog? i will be to the great extent than happy to reciprocate and put your link off in the link exchange area. waiting for your reply, i would like to convey my appreciation and gooday!

injury lawyer United States | Reply

27/7/2010 9:46:36 #

order custom essays

The essay writer paper written by experts, should give different people a success. Thence it’s valuable to buy essay papers to get your aim, I guess.

order custom essays Canada | Reply

28/7/2010 23:09:45 #

Buy essays

The simple pass way to get know about this good topic is to order already written essay or buy essay.

Buy essays Canada | Reply

30/7/2010 10:09:14 #

written essays

You should spend a lot of free time to create your academic papers, but a distinguished buy writing paper service will be able to do that much faster. What for compose academic papers? Custom writing companies will do it for you.

written essays Canada | Reply

2/8/2010 8:42:24 #

flowers delivery

Really like this website, this really helps and very useful.I love flowers...I am also interested to send flowers all over the world....

flowers delivery | Reply

6/8/2010 7:51:03 #

custom dissertation

If you would like to know more close to this post, search for custom thesis or dissertation writing and order good enough history dissertation there.

custom dissertation Canada | Reply

9/8/2010 5:47:06 #

macaroon

I remember thus its nice useful and cognition able.I would care to thank you for the movements you make successful in writing this article. I am desiring the same best work Quotes early as better.

macaroon United States | Reply

10/8/2010 17:22:45 #

buy thesis

The the easiest way to check out the professionalism of the buy thesis services was to buy the good enough writing thesis relating with this topic at the buy dissertation service.                              

buy thesis Canada | Reply

12/8/2010 6:07:48 #

essays online

Left you some star on my blog, i hope this would aid you. What companies would support students in writing? I will advice to get the essay service.

essays online Canada | Reply

12/8/2010 14:41:14 #

dissertation service

We could get dissertation writing or dissertation idea. But to show that you are a good students, you would use a thesis.

dissertation service Canada | Reply

14/8/2010 17:02:43 #

大愛徵信

I have heard a lot on this point, but it seems to me that your throught are the best.I like the post very much.

大愛徵信 Taiwan | Reply

16/8/2010 22:41:53 #

Fußmatten

Great blog with such nice articles

Fußmatten Germany | Reply

17/8/2010 0:51:45 #

cosplay

Great blog with such nice articles

cosplay Japan | Reply

17/8/2010 3:02:45 #

angular cheilitis treatment

Is there an english translation of this blog page available somewhere?

angular cheilitis treatment United States | Reply

17/8/2010 6:08:53 #

cosplay

Bu gun Azerbaycanda cetin olsada Rusiyada arxiv senedleri ile tanish olmaq o qederde cetin deyil. Kimin Mircelladin Azerbaycana, azerbaycan xalqina, azerbaycanin ziyali dunyasina etdiyi pisliklere, vurdugu yaralara shubhesi varsa buyursun gelsin Rusiyada arxivlerde yatan senedlerle tanish olsun.etdiyi

cosplay Japan | Reply

18/8/2010 3:03:38 #

Outdoor Garden Fountains

nice, very nice indeed.

Outdoor Garden Fountains United States | Reply

18/8/2010 16:18:48 #

vigrx

your site layout is very good

vigrx United States | Reply

20/8/2010 4:25:48 #

cheap uggs

Thanks for sharing,UGG Boots are appreciated by more and more people,cheap and top quality,
http://www.cheap-ugg.net/
cheap uggs are given a hearted welcome.here Cheap Ugg Boots are on wholesale.Keep going!!!

cheap uggs People's Republic of China | Reply

21/8/2010 1:44:26 #

quick shade canopy

Hmm well, very interesting, thanks for the info.

quick shade canopy United States | Reply

22/8/2010 3:28:46 #

killer sudoku

Is there any applications for an online killer sudoku project? <a href="http://killersudoku.info">killer sudoku</a> is a sudoku site similar to what I mean

killer sudoku United States | Reply

22/8/2010 16:49:30 #

course work writing service

I often choose to buy coursework online. That is smart because it is fast. Furhtermore, it gets me an advantage.

course work writing service Canada | Reply

24/8/2010 2:52:44 #

nail polish kits

Hey this is a great post, thanks for the share.

nail polish kits United States | Reply

25/8/2010 1:15:12 #

collapsible water bottle

Nice site, thanks for the information, i enjoyed the read

collapsible water bottle United States | Reply

28/8/2010 13:52:01 #

Prada Shoes

That is a great post, thanks for sharing it’s greatly appreciated Smile
When will you start blogging more frequently?

Prada Shoes United States | Reply

29/8/2010 1:23:40 #

proven penis enlargement

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. Albert Einstein (1879-1955)

proven penis enlargement Taiwan | Reply

30/8/2010 22:54:37 #

luau party invitations

Great topic, even better discussion, really.

luau party invitations United States | Reply

31/8/2010 14:16:31 #

online essay

To be successful means to have the high grades and for that, students must demonstrate the high quality essay paper. But is it available to accomplish it not using a support of the news writing service? Yes, that’s real, but it will be more simple to buy do my paper essay just about this good topic in web.

online essay United States | Reply

1/9/2010 5:18:16 #

essays help

Right. I like very much the articles drafted in view of this. A shopmate announce me your site, ever since my first visit, I have been absorbed. Don't spend your life in questions and concerns, just order original custom papers. Keep the articles coming!

essays help United States | Reply

1/9/2010 7:05:24 #

china printing

We provide you with high-quality China Printing Services like printed boxes and packaging products at competitive prices from china.

china printing People's Republic of China | Reply

6/9/2010 5:22:41 #

Storage

I was very pleased to find this site. I wanted to thank you for this great read!!

Storage United States | Reply

8/9/2010 3:24:48 #

nail polish holder

Nice site, good info, good good good. heh

nail polish holder United States | Reply

Comentar




  Country flag

biuquote
  • Comentário
  • Pré-visualização
Loading



Sobre mim

Ricardo Dorta

Ricardo Dorta

Arquiteto de sistemas da Makesys, atua na área de desenvolvimento de aplicações .NET há 5 anos.
MCP, MCAD e MCSD.