webForumDet fria alternativet

Bläddra mellan bilder (newbie)

.NET

11 svar · 518 visningar · startad av airwolf

Medlem sedan okt. 2003132 inlägg
Frågan#1

Jag har en sida som läser ut exif ur en bild, nu vill jag att
man ska kunna bläddra mellan de olika bilderna i en mapp.

Framåt och bakåt.
Jag har ingen aning om hur jag ska lyckas med detta.
Går det på nåt sätt att lista bilderna i bokstavsordning,
så den vet att är jag på den här finns den nästa fram och den nästa bakåt

Medlem sedan dec. 19996 522 inlägg
#2

Du kan ju läsa in dem i en string[], eller en collection av Image objekt.

Medlem sedan juni 2001145 inlägg
#3

http://aspnet.4guysfromrolla.com/articles/070704-1.aspx : Där hittar du ett exempel på det du vill göra.. (tror jag).

Medlem sedan okt. 2003132 inlägg
#4

kanon!
Återkommer med resultat

Medlem sedan okt. 2003132 inlägg
#5

hmmm, nu behöver jag "bara" hjälp med att para dessa filer,
nån som vill hjälpa?

(hatar att vara newbie)

Medlem sedan apr. 20012 266 inlägg
#6

Exakt vad vill du göra? Hur skall de paras ihop?

Medlem sedan okt. 2003132 inlägg
#7

jag har en sida som tar ut exif data ur en bild, jag skulle vilja para ihop den med sidbläddringen på http://aspnet.4guysfromrolla.com/articles/070704-1.aspx

Medlem sedan apr. 20012 266 inlägg
#8

Enligt exemplet i länken ovan läggs alla sökvägar till bilderna in i en string array, för att få ut den aktuella bilden använder du denna kod enligt exemplet:

string path = images(imgIndex);

Denna path borde du sedan kunna använda i din exif funktion för att hämta data.

Medlem sedan okt. 2003132 inlägg
#9

Så här ser sidan ut i dagsläget, man klickar på mapp och väljer bild, då visas exif.aspx
Det är den sidan jag vill att man ska kunna bläddra mellan bilderna på.

Kod:
exif.aspx

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%
	
	Dim objImage As Drawing.Image
    Dim arrProps As PropertyItem()
    Dim objProp As PropertyItem
    Dim strReturn As String
    Dim blnIsEXIFFile As Boolean
    Dim intRecip As Integer
    Dim intVal As Integer
    Dim strModel As String
    Dim strDate As String
    Dim strExposureTime As String
    Dim strFStop As String
    Dim strFocalLength As String
    Dim strISOSpeed As String
    Dim strMeteringMode As String
    Dim strLightSource As String
    Dim strExposureProgram As String
    Dim strTemp As String
    Dim arrByte As Byte()
    Dim intCounter As Integer
    Dim strFileName as string
    Dim strSize
    Dim strISO as string
    
    strFileName = Request.QueryString("photo")
    strSize = Request.QueryString("z")
    
    objImage = System.Drawing.Image.FromFile(MapPath(strFileName))
    arrProps = objImage.PropertyItems

    blnIsEXIFFile = False

    For Each objProp In arrProps
        
        Select Case objProp.Id
            Case 272 'Model

                arrByte = objProp.Value
                For intCounter = 0 To arrByte.GetUpperBound(0)
                    If Not arrByte(intCounter) = 0 Then 'Strips off "end of string" Byte if present
                        strTemp &= Chr(arrByte(intCounter))
                    End If
                Next
                strModel = RTrim(strTemp)
				blnIsEXIFFile = True

            Case 306 'DateTime

                strTemp = System.Text.Encoding.ASCII.GetString(objProp.Value)
                'Reformat the Date from yyyy:mm:dd hh:mm:ss to YYYY-MM-DDDD
                strDate = Mid(strTemp, 1, 4) & "-" 'Year
                strDate &= Mid(strTemp, 9, 2) & "-" 'Month
                strDate &= Mid(strTemp, 6, 2) 'Da
				blnIsEXIFFile = True

            Case 33434 'Exposure Time

                If System.BitConverter.ToInt32(objProp.Value, 0) >= System.BitConverter.ToInt32(objProp.Value, 4) Then
                    strExposureTime = (System.BitConverter.ToInt32(objProp.Value, 0) / System.BitConverter.ToInt32(objProp.Value, 4)) & " Sec"
                Else
                    intVal = 1
                    intRecip = System.BitConverter.ToInt32(objProp.Value, 4) / System.BitConverter.ToInt32(objProp.Value, 0)
                    strExposureTime = intVal & "/" & intRecip & " Sec"
                End If
				blnIsEXIFFile = True
            Case 33437 'FStop

                strFStop = "F" & (System.BitConverter.ToInt32(objProp.Value, 0) / System.BitConverter.ToInt32(objProp.Value, 4))
				blnIsEXIFFile = True
            Case 37386 'Focal Length

                strFocalLength = (System.BitConverter.ToInt32(objProp.Value, 0) / System.BitConverter.ToInt32(objProp.Value, 4)) & "mm"
  				blnIsEXIFFile = True
            Case 37383 'Metering Mode
				strTemp = System.BitConverter.ToUInt16(objProp.Value, 0).ToString
				
				Select Case strTemp
					Case "1"
						strMeteringMode = "Average"
					Case "2"
						strMeteringMode = "Center Weighted Ave"
					Case "3"
						strMeteringMode = "Spot"
					Case "4"
						strMeteringMode = "Multi-Spot"
					Case "5"
						strMeteringMode = "Pattern"
					Case "6"
						strMeteringMode = "Partial"
					Case Else
						strMeteringMode = "Other"
				End Select
						
				blnIsEXIFFile = True
            Case 37385 'Flash
				strTemp =  System.BitConverter.ToUInt16(objProp.Value, 0).ToString
				Select Case strTemp
					Case "0"
						strLightSource = "Yes"
					Case Else
						strLightSource = "No"
				End Select

				blnIsEXIFFile = True
            Case 34850 'Exposure Program
				strTemp = System.BitConverter.ToUInt16(objProp.Value, 0).ToString
			
				Select Case strTemp
					Case "1"
						strExposureProgram = "Manual"
					Case "2"
						strExposureProgram = "Normal Program"
					Case "3"
						strExposureProgram = "Aperature Priority"
					Case "4"
						strExposureProgram = "Shutter Priority"
					Case "5"
						strExposureProgram = "Creative Program"
					Case "6"
						strExposureProgram = "Action Program"
					Case "7"
						strExposureProgram = "Portrait Mode"
					Case "8"
						strExposureProgram = "Landscape Mode"
					Case Else
						strExposureProgram = "Unknown"
				End Select
   
				blnIsEXIFFile = True
               Case 34855 'ISO
               strISO = System.BitConverter.ToUInt16(objProp.Value, 0).ToString
                  
				blnIsEXIFFile = True
        End Select
    Next

%>
<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<meta name="generator" content="Microsoft .net">
		<title>© Daniel Gustafsson - Mixed Albums</title>
        <style type="text/css">
        <!--

        A:link, A:active { color: #FF9900; text-decoration: underline; }
        A:visited { color: #FF9900; text-decoration: underline; }
        A:hover { color: #FF9900; text-decoration: none; }

        .text { font-family: Verdana, Arial, Helvetica; font-size: 9px; color: #222222; }

        -->
</style>
	</head>
    <body topmargin="40">
    <center>
			<p>
            <img border=0 src='myResize.aspx?src=<%=strFileName%>&z=<%=strSize%>' Style="FILTER:progid:DXImageTransform.Microsoft.Shadow(color='#333333', Direction=120, Strength=7)">
            <br>
            <center><font size='2' face='Tahoma,Arial' color='#000000'>Other sizes: 
            <a href='exif.aspx?photo=<%= strFileName %>&z=2'>Small</a>
            <a href='exif.aspx?photo=<%= strFileName %>&z=6'>Medium</a>
            <a href='exif.aspx?photo=<%= strFileName %>&z=12'>Large</a>
            <a href='exif.aspx?photo=<%= strFileName %>&z=1000'>Original</a><br>
			<% IF blnISEXIFFile Then %>
			<Table width=650 border='0' cellpadding='2' cellspacing='1' width='80%' bgcolor='black' ID="Table1" Style="FILTER:progid:DXImageTransform.Microsoft.Shadow(color='#333333', Direction=120, Strength=5)">
				<TR>
					<TH bgcolor='#F6F6F6'><center><font size='1' face='Tahoma,Arial' color='#000000'>Camera</center></TH>
					<TH bgcolor='#F6F6F6'><center><font size='1' face='Tahoma,Arial' color='#000000'>Date</center></TH>
					<TH bgcolor='#F6F6F6'><center><font size='1' face='Tahoma,Arial' color='#000000'>Exposure Time</center></TH>
					<TH bgcolor='#F6F6F6'><center><font size='1' face='Tahoma,Arial' color='#000000'>Aperture</center></TH>
                    <TH bgcolor='#F6F6F6'><center><font size='1' face='Tahoma,Arial' color='#000000'>ISO</center></TH>
					<TH bgcolor='#F6F6F6'><center><font size='1' face='Tahoma,Arial' color='#000000'>Focal Length</center></TH>
					<TH bgcolor='#F6F6F6'><center><font size='1' face='Tahoma,Arial' color='#000000'>Metering Mode</center></TH>
					<TH bgcolor='#F6F6F6'><center><font size='1' face='Tahoma,Arial' color='#000000'>Flash</center></TH>
					<TH bgcolor='#F6F6F6'><center><font size='1' face='Tahoma,Arial' color='#000000'>Exposure Program</center></TH>
				</TR>
				<TR>
					<TD bgcolor='#FFFFFF'><center><font size='1' face='Tahoma,Arial' color='black'><%=strModel %></center></TD>
					<TD bgcolor='#FFFFFF'><center><font size='1' face='Tahoma,Arial' color='black'><%=strDate %></center></TD>
					<TD bgcolor='#FFFFFF'><center><font size='1' face='Tahoma,Arial' color='black'><%=strExposureTime %></center></TD>
					<TD bgcolor='#FFFFFF'><center><font size='1' face='Tahoma,Arial' color='black'><%=strFStop %></center></TD>
					<TD bgcolor='#FFFFFF'><center><font size='1' face='Tahoma,Arial' color='black'><%=strISO %></center></TD>
					<TD bgcolor='#FFFFFF'><center><font size='1' face='Tahoma,Arial' color='black'><%=strFocalLength %></center></TD>
					<TD bgcolor='#FFFFFF'><center><font size='1' face='Tahoma,Arial' color='black'><%=strMeteringMode %></center></TD>
					<TD bgcolor='#FFFFFF'><center><font size='1' face='Tahoma,Arial' color='black'><%=strLightSource %></center></TD>
					<TD bgcolor='#FFFFFF'><center><font size='1' face='Tahoma,Arial' color='black'><%=strExposureProgram %></center></TD>
				</TR>
			</Table>
			<% Else %>
            <Table width=650 border='0' cellpadding='2' cellspacing='1' width='80%' bgcolor='black' ID="Table1" Style="FILTER:progid:DXImageTransform.Microsoft.Shadow(color='#333333', Direction=120, Strength=5)">
			    <TR>
                  <TH bgcolor='#F6F6F6'><center><font size='1' face='Tahoma,Arial' color='#000000'>This file does not contain any EXIF Data.</center></TH>
                </TR>
            </Table>
			<% End If %>
			<br>
			<p><br>

		</center>
	</body>

</html>

Detta koden från http://aspnet.4guysfromrolla.com/London/

som har funktionen jag vill ha i ovanstående sida.

Kan nån av er experter sy ihop dessa, förklara gärna..

/Daniel

Medlem sedan okt. 2003132 inlägg
#10

ingen som har ett förslag?

Medlem sedan okt. 2003132 inlägg
#11

Jag har ett annat problem med ovanstående script.
Den spottar inte ut Case Else.

Allt förutom case else funkar, nån som har en ide om det?

Medlem sedan okt. 2003132 inlägg
#12

Jag har hittat felet tror jag.
Ifall case inte innehåller nåt så reagerar inte case Else.

Nån som har en lösning på det?

284 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
133 ms — deklarationer (db)
0 ms — hämta statistik (cache)
148 ms — hämta tråd, inlägg och bilagor (db)
133 ms — ändringar (db)