Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0A page for creating thumbnails wonA page for creating thumbnails won't work
Previous
 
Next
New Post
6/16/2008 10:03 AM
 

Hi all,

I create a Thumbnail.aspx page for creating thumbnails on the fly, the problem is that the page works perfectly on any ASP.NET Application but not when i use it in my custom DDN Module and I don't understand why.

This is the page code:

 Partial Public Class ThumbnailInherits System.Web.UI.PagePrivate Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.LoadDim strPath As String = Request.QueryString("p")Dim strImg As String = Request.QueryString("i")Dim intW As Integer = Request.QueryString("w")Dim intH As Integer = Request.QueryString("h")'original image

 

 

 

 

Dim objImage As System.Drawing.Image = New Bitmap(Server.MapPath(strPath & strImg))Dim intImgW As Integer = objImage.WidthDim intImgH As Integer = objImage.Height'new width and height

 

Dim intThumbW As Integer

 

Dim intThumbH As Integer

 

If intImgW >= intW And intImgH >= intH Then

 

If intImgW > intImgH Then

intThumbW = intW

intThumbH = (intH * intImgH) / intImgW

 

Else

intThumbW = (intH / intImgH) * intImgW

intThumbH = intH

 

End If

 

ElseIf intImgW <= intW And intImgH <= intH Then

intThumbW = intImgW

intThumbH = intImgH

 

ElseIf intImgW >= intW And intImgH <= intH Then

intThumbW = intW

intThumbH = (intH * intImgH) / intImgW

 

ElseIf intImgW <= intW And intImgH >= intH Then

intThumbW = (intH / intImgH) * intImgW

intThumbH = intH

 

End If

 

'miniature

 

 

Dim objThumbImage As System.Drawing.Image'image codec info

 

 

 

 

Dim myImageCodecInfo As System.Drawing.Imaging.ImageCodecInfoDim Encoders As System.Drawing.Imaging.ImageCodecInfo() = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()For i As Integer = 0 To (Encoders.Length - 1)If (Encoders(i).MimeType = "image/jpeg") Then

myImageCodecInfo = Encoders(i)

 

End If

 

 

Next i'parameters

 

myEncoderParameters =

 

Dim myEncoderParameters As System.Drawing.Imaging.EncoderParametersNew System.Drawing.Imaging.EncoderParameters(1)'encoder quality, value compression

 

 

Dim myEncoderQuality As System.Drawing.Imaging.Encoder = System.Drawing.Imaging.Encoder.QualityDim Compression As Long

 

If Trim(Request.QueryString("c")) = "" Then

Compression = 100

 

Else

Compression =

 

Long.Parse(Request.QueryString("c"))End If

 

'quality parameter

 

myEncoderParameterQuality =

 

Dim myEncoderParameterQuality As System.Drawing.Imaging.EncoderParameterNew System.Drawing.Imaging.EncoderParameter(myEncoderQuality, Compression)'add quality parameter to parameters

myEncoderParameters.Param(0) = myEncoderParameterQuality

 

callback =

objThumbImage = objImage.GetThumbnailImage(intThumbW, intThumbH, callback, IntPtr.Zero)

 

Dim callback As System.Drawing.Image.GetThumbnailImageAbortNew System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)'crop --------------------------------------------------------------------------------------------------------------------

 

'Dim objDrawImage As New System.Drawing.Bitmap(intW, intH, PixelFormat.Format24bppRgb)

 

'Dim objGraphics As Graphics = Graphics.FromImage(objDrawImage)

 

'objGraphics.CompositingQuality = CompositingQuality.HighQuality

 

'objGraphics.SmoothingMode = SmoothingMode.AntiAlias

 

'objGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic

 

'Dim intXSize As Integer = objThumbImage.Width - 1

 

'Dim intYSize As Integer = objThumbImage.Height - 1

 

'Dim intHalfWidth As Integer = intXSize / 2

 

'Dim intHalfHeight As Integer = intYSize / 2

 

'Dim X As Integer = intHalfWidth - (intW / 2)

 

'Dim Y As Integer = intHalfHeight - (intH / 2)

 

'objGraphics.DrawImage(objThumbImage, New Rectangle(0, 0, intW, intH), New Rectangle(X, Y, intW, intH), GraphicsUnit.Pixel)

 

'objThumbImage.Dispose()

 

'-------------------------------------------------------------------------------------------------------------------------

Response.ContentType =

"image/jpeg"

 

'objDrawImage.Save(Response.OutputStream, myImageCodecInfo, myEncoderParameters)

objThumbImage.Save(Response.OutputStream, myImageCodecInfo, myEncoderParameters)

objImage.Dispose()

objThumbImage.Dispose()

 

'objGraphics.Dispose()

 

'objDrawImage.Dispose()

 

 

 

Maybe the problem is the use of AJAX in my module?

Thank you for your help! :-)

End Sub 

 

 

 

 

 

 

 

 

 
New Post
6/16/2008 12:53 PM
 

Hi Luca,

what error do you receive?

Best regards,
Dario Rossa

 
New Post
6/16/2008 1:19 PM
 

Dario Rossa wrote

Hi Luca,

what error do you receive?

Best regards,
Dario Rossa

Hi Dario,

thank you for your answer, simply the image is not displayed. The X of not existing image is showed insted of the image.

 
New Post
6/16/2008 9:07 PM
 

Is there any reason why you are using the Page clas and not an IHttpHandler? This is what I do on my UserProfile module:

 

    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Profile : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {

            ..blurb..
        }

        public bool IsReusable
        {
            get
            {
                return true;
            }
        }
    }


Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
New Post
6/17/2008 1:17 AM
 

You should view property of the red x to gain clues as to the problem which is most likely that you are calling the page at a location where it does not exist.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0A page for creating thumbnails wonA page for creating thumbnails won't work


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out