elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


  Mostrar Mensajes
Páginas: 1 ... 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 [323] 324 325 326 327 328 329 330 331
3221  Programación / Programación Visual Basic / HDC a Picture en: 22 Septiembre 2008, 06:55 am

HDC a Picture

con respecto a los PNG seria cargarlo a el modulo y despues transformarlo a pictura o bitmap  ve esta funcion sacada de la Api-Guide

la funcion en si transforma de un Hdc a Picture ok' [como ejemplo poongo este codigo completo de la Api-Guide]
Código
  1. Const RC_PALETTE As Long = &H100
  2. Const SIZEPALETTE As Long = 104
  3. Const RASTERCAPS As Long = 38
  4. Private Type PALETTEENTRY
  5.    peRed As Byte
  6.    peGreen As Byte
  7.    peBlue As Byte
  8.    peFlags As Byte
  9. End Type
  10. Private Type LOGPALETTE
  11.    palVersion As Integer
  12.    palNumEntries As Integer
  13.    palPalEntry(255) As PALETTEENTRY ' Enough for 256 colors
  14. End Type
  15. Private Type GUID
  16.    Data1 As Long
  17.    Data2 As Integer
  18.    Data3 As Integer
  19.    Data4(7) As Byte
  20. End Type
  21. Private Type PicBmp
  22.    Size As Long
  23.    Type As Long
  24.    hBmp As Long
  25.    hPal As Long
  26.    Reserved As Long
  27. End Type
  28. Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
  29. Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
  30. Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
  31. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  32. Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal iCapabilitiy As Long) As Long
  33. Private Declare Function GetSystemPaletteEntries Lib "gdi32" (ByVal hdc As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteEntries As PALETTEENTRY) As Long
  34. Private Declare Function CreatePalette Lib "gdi32" (lpLogPalette As LOGPALETTE) As Long
  35. Private Declare Function SelectPalette Lib "gdi32" (ByVal hdc As Long, ByVal hPalette As Long, ByVal bForceBackground As Long) As Long
  36. Private Declare Function RealizePalette Lib "gdi32" (ByVal hdc As Long) As Long
  37. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  38. Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
  39. Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
  40. Function CreateBitmapPicture(ByVal hBmp As Long, ByVal hPal As Long) As Picture
  41.    Dim R As Long, Pic As PicBmp, IPic As IPicture, IID_IDispatch As GUID
  42.  
  43.    'Fill GUID info
  44.    With IID_IDispatch
  45.        .Data1 = &H20400
  46.        .Data4(0) = &HC0
  47.        .Data4(7) = &H46
  48.    End With
  49.  
  50.    'Fill picture info
  51.    With Pic
  52.        .Size = Len(Pic) ' Length of structure
  53.        .Type = vbPicTypeBitmap ' Type of Picture (bitmap)
  54.        .hBmp = hBmp ' Handle to bitmap
  55.        .hPal = hPal ' Handle to palette (may be null)
  56.    End With
  57.  
  58.    'Create the picture
  59.    R = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic)
  60.  
  61.    'Return the new picture
  62.    Set CreateBitmapPicture = IPic
  63. End Function
  64. Function hDCToPicture(ByVal hDCSrc As Long, ByVal LeftSrc As Long, ByVal TopSrc As Long, ByVal WidthSrc As Long, ByVal HeightSrc As Long) As Picture
  65.    Dim hDCMemory As Long, hBmp As Long, hBmpPrev As Long, R As Long
  66.    Dim hPal As Long, hPalPrev As Long, RasterCapsScrn As Long, HasPaletteScrn As Long
  67.    Dim PaletteSizeScrn As Long, LogPal As LOGPALETTE
  68.  
  69.    'Create a compatible device context
  70.    hDCMemory = CreateCompatibleDC(hDCSrc)
  71.    'Create a compatible bitmap
  72.    hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc)
  73.    'Select the compatible bitmap into our compatible device context
  74.    hBmpPrev = SelectObject(hDCMemory, hBmp)
  75.  
  76.    'Raster capabilities?
  77.    RasterCapsScrn = GetDeviceCaps(hDCSrc, RASTERCAPS) ' Raster
  78.    'Does our picture use a palette?
  79.    HasPaletteScrn = RasterCapsScrn And RC_PALETTE ' Palette
  80.    'What's the size of that palette?
  81.    PaletteSizeScrn = GetDeviceCaps(hDCSrc, SIZEPALETTE) ' Size of
  82.  
  83.    If HasPaletteScrn And (PaletteSizeScrn = 256) Then
  84.        'Set the palette version
  85.        LogPal.palVersion = &H300
  86.        'Number of palette entries
  87.        LogPal.palNumEntries = 256
  88.        'Retrieve the system palette entries
  89.        R = GetSystemPaletteEntries(hDCSrc, 0, 256, LogPal.palPalEntry(0))
  90.        'Create the palette
  91.        hPal = CreatePalette(LogPal)
  92.        'Select the palette
  93.        hPalPrev = SelectPalette(hDCMemory, hPal, 0)
  94.        'Realize the palette
  95.        R = RealizePalette(hDCMemory)
  96.    End If
  97.  
  98.    'Copy the source image to our compatible device context
  99.    R = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy)
  100.  
  101.    'Restore the old bitmap
  102.    hBmp = SelectObject(hDCMemory, hBmpPrev)
  103.  
  104.    If HasPaletteScrn And (PaletteSizeScrn = 256) Then
  105.        'Select the palette
  106.        hPal = SelectPalette(hDCMemory, hPalPrev, 0)
  107.    End If
  108.  
  109.    'Delete our memory DC
  110.    R = DeleteDC(hDCMemory)
  111.  
  112.    Set hDCToPicture = CreateBitmapPicture(hBmp, hPal)
  113. End Function
  114. Private Sub Form_Load()
  115.    'KPD-Team 1999
  116.    'URL: http://www.allapi.net/
  117.    'E-Mail: KPDTeam@Allapi.net
  118.    'Create a picture object from the screen
  119.    Set Me.Picture = hDCToPicture(GetDC(0), 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY)
  120. End Sub
  121.  

solo edita la linea siguiente y edita los datos requeridos

Código
  1.    Set Picture2.Picture = hDCToPicture(Picture1.hdc, 0, 0, 100, 100)
  2. []/code[
3222  Programación / Programación Visual Basic / Re: Una ayudita pliss en: 22 Septiembre 2008, 06:47 am
DrawText.

Código
  1. Const DC_ACTIVE = &H1
  2. Const DC_NOTACTIVE = &H2
  3. Const DC_ICON = &H4
  4. Const DC_TEXT = &H8
  5. Const BDR_SUNKENOUTER = &H2
  6. Const BDR_RAISEDINNER = &H4
  7. Const EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
  8. Const BF_BOTTOM = &H8
  9. Const BF_LEFT = &H1
  10. Const BF_RIGHT = &H4
  11. Const BF_TOP = &H2
  12. Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
  13. Const DFC_BUTTON = 4
  14. Const DFC_POPUPMENU = 5            'Solo Win98/2000 !!
  15. Const DFCS_BUTTON3STATE = &H10
  16. Const DT_CENTER = &H1
  17. Const DC_GRADIENT = &H20          'Solo Win98/2000 !!
  18.  
  19. Private Type RECT
  20.    Left As Long
  21.    Top As Long
  22.    Right As Long
  23.    Bottom As Long
  24. End Type
  25. Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
  26. Private Sub Form_Load()
  27. AutoRedraw = True
  28. Dim r As RECT
  29. r.Top = 0
  30. r.Left = 0
  31. r.Bottom = 20
  32. r.Right = 500
  33. DrawText Me.hdc, "Holaaaaaaaaaa", Len("Holaaaaaaaaaa"), r, BF_RECT Or BF_TOP
  34. End Sub
  35.  

BitBlt

usa dos piture en el picture1 carga alguna imagen en el segundo no pogas nada
Código
  1. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  2. Private Sub Form_Load()
  3. Picture1.ScaleMode = 3
  4. Picture2.ScaleMode = 3
  5. Picture1.AutoRedraw = True
  6. Picture2.AutoRedraw = True
  7. r = BitBlt(Picture2.hdc, 0, 0, 100, 100, Picture1.hdc, 10, 10, vbSrcCopy)
  8. End Sub
  9.  

Transparect Blt (Sacado de la Api-Guide)

Código
  1. 'This project needs 2 pictureboxes
  2. 'Picturebox1 must contain a picture with a lot of white pixels (we're going to use white as transparent color)
  3. Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
  4. Private Sub Form_Load()
  5.    'KPD-Team 1999
  6.    'URL: http://www.allapi.net/
  7.    'E-Mail: KPDTeam@Allapi.net
  8.    Picture1.AutoSize = True
  9.    'API uses pixels
  10.    Picture1.ScaleMode = vbPixels
  11.    Picture2.ScaleMode = vbPixels
  12. End Sub
  13. Private Sub Picture2_Paint()
  14.    'If we don't call DoEvents first, our transparent image will be completely wrong
  15.    DoEvents
  16.    TransparentBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbWhite
  17. End Sub
  18.  
3223  Programación / Programación Visual Basic / Re: Una ayudita pliss en: 22 Septiembre 2008, 02:34 am
PaintPicture
las demas estan ya posteadas me parece en este foro si no busca en la Api-Guide
3224  Programación / Programación Visual Basic / Re: Una ayudita pliss en: 21 Septiembre 2008, 09:30 am
Como NO pides ejemplos de coigos mejor te voy al punto sin tanto rollo

Parala imagen:
   con PaintPicture  o con la api bitblt
      combinarlo con TransparentBlt  para transparencias un X color
Para texto:
   Api DrawText
3225  Programación / Programación Visual Basic / Re: Redimensionar imagen???? en: 20 Septiembre 2008, 05:40 am
Hola,yo creo que con un PaintPicture te alcanza...

saludos.

lo mismo digo, aun que la funcion que puse detecta escala la imagen a el picture y lo ajusta a este sin importar el tamaño de la imagen a cargar y no distorciona la imagen en cuestion de anchura y altura je (probarlo para verlo mejor)

Código
  1. r=cargarredimencionarimg("c:\img.jpg",picture1)

3226  Programación / Programación Visual Basic / Re: como crear funcion que? en: 20 Septiembre 2008, 02:38 am
Código
  1. Private Function RndString(ByVal LongString As Integer) As String
  2. Dim I As Integer
  3.    Randomize Timer
  4.    For I = 0 To LongString
  5.        Select Case (Int((3 * Rnd) + 1))
  6.            Case 1: RndString = RndString & Chr$(Int((10 * Rnd) + 48))
  7.            Case 2: RndString = RndString & Chr$(Int((26 * Rnd) + 65))
  8.            Case 3: RndString = RndString & Chr$(Int((26 * Rnd) + 97))
  9.        End Select
  10.    Next
  11. End Function

Corrigiendo xP

Código
  1. Private Function RndString(ByVal LongString As Integer) As String
  2. Dim I As Integer
  3.    Randomize Timer
  4.    For I = 1 To LongString
  5.        Select Case (Int((3 * Rnd) + 1))
  6.            Case 1: RndString = RndString & Chr$(Int((10 * Rnd) + 48))
  7.            Case 2: RndString = RndString & Chr$(Int((26 * Rnd) + 65))
  8.            Case 3: RndString = RndString & Chr$(Int((26 * Rnd) + 97))
  9.        End Select
  10.    Next
  11. End Function


el anterior me daba 11 caracteres cuando yo pedia 10 je xP este me gusta mas
3227  Programación / Programación Visual Basic / Re: Redimensionar imagen???? en: 20 Septiembre 2008, 02:12 am
Aca esta el codigo espero y te agrade

Código
  1. Dim ImagenFoto As IPictureDisp
  2. Public Function CargarRedimencionarIMG(sRuta As String, _
  3.                        PictureFix As PictureBox, _
  4.                        Optional ByVal Pic_Ancho As Double, _
  5.                        Optional ByVal Pic_Alto As Double, _
  6.                        Optional ByVal X As Integer = 0, _
  7.                        Optional ByVal Y As Integer = 0, _
  8.                        Optional ByVal X2 = 0, _
  9.                        Optional ByVal Y2 = 0, _
  10.                        Optional ByVal Ancho2, _
  11.                        Optional ByVal Alto2, _
  12.                        Optional Opcional) As Long
  13.  
  14.    On Error GoTo Nel:
  15.  
  16.    Dim Ancho As Single, Alto As Single, Porcentaje As Single
  17.  
  18.    Pic_Ancho = IIf(Pic_Ancho <= 0, PictureFix.Width, Pic_Ancho)
  19.    Pic_Alto = IIf(Pic_Alto <= 0, PictureFix.Height, Pic_Alto)
  20.  
  21.    PictureFix.Width = Val(Pic_Ancho): PictureFix.Height = Val(Pic_Alto)
  22.    PictureFix.Cls
  23.    Set ImagenFoto = LoadPicture(sRuta)
  24.    Ancho = ImagenFoto.Width
  25.    Alto = ImagenFoto.Height
  26.    If Ancho < PictureFix.Width And Alto < PictureFix.Height Then
  27.        Porcentaje = 100
  28.        CargarRedimencionarIMG = CentrarPicture(PictureFix, Ancho, Alto, X, Y, Porcentaje, X2, Y2, Ancho2, Alto2, Opcional)
  29.        Exit Function
  30.    End If
  31.    If Ancho > PictureFix.Width Or Alto > PictureFix.Height Then
  32.        If Ancho > Alto Then
  33.            Porcentaje = (PictureFix.Width * 100) / Ancho
  34.        Else
  35.            Porcentaje = (PictureFix.Height * 100) / Alto
  36.        End If
  37.        CargarRedimencionarIMG = CentrarPicture(PictureFix, Ancho, Alto, X, Y, Porcentaje, X2, Y2, Ancho2, Alto2, Opcional)
  38.        Exit Function
  39.    ElseIf Ancho <= PictureFix.Width Or Alto <= PictureFix.Height Then
  40.        If Ancho > Alto Then
  41.            Porcentaje = (PictureFix.Width * 100) / Ancho
  42.        Else
  43.            Porcentaje = (PictureFix.Width * 100) / Alto
  44.        End If
  45.        CargarRedimencionarIMG = CentrarPicture(PictureFix, Ancho, Alto, X, Y, Porcentaje, X2, Y2, Ancho2, Alto2, Opcional)
  46.    End If
  47.    Exit Function
  48. Nel:
  49.    Cargar = 0
  50.    Err.Clear
  51. End Function
  52. Private Function CentrarPicture(PictureFix As PictureBox, _
  53.                                Optional ByVal Ancho As Double, _
  54.                                Optional ByVal Alto As Double, _
  55.                                Optional ByVal X As Integer = 0, _
  56.                                Optional ByVal Y As Integer = 0, _
  57.                                Optional Porcentaje As Single = 100, _
  58.                                Optional ByVal X2 As Integer = 0, _
  59.                                Optional ByVal Y2 As Integer = 0, _
  60.                                Optional ByVal Ancho2, _
  61.                                Optional ByVal Alto2, _
  62.                                Optional Opcional) As Long
  63.    On Error GoTo Nel
  64.    Ancho = (Ancho * Porcentaje) / 100
  65.    Alto = (Alto * Porcentaje) / 100
  66.    PictureFix.Width = Ancho
  67.    PictureFix.Height = Alto
  68.    PictureFix.PaintPicture ImagenFoto, X, Y, Ancho, Alto, X2, Y2, Ancho2, Alto2, Opcional
  69.    CentrarPicture = 1
  70.    Exit Function
  71. Nel:
  72.    CentrarPicture = 0
  73.    Err.Clear
  74. End Function
  75.  
3228  Programación / Programación Visual Basic / Re: Split replacement en: 18 Septiembre 2008, 01:15 am
yo cuando aprendia apenas VB hice algo similar solo que mi codigo era muuuy largo xS obviamente apenas empesaba y no por maestros si no por mi propia cuenta y ejemplos descargados era mas o menos el doble o triple de tu codigo je xP haber i lo ayo y lo pongo je.

Aun asi esta bueno xP
3229  Programación / Programación Visual Basic / Re: Se puede hacer esto con API's?? en: 18 Septiembre 2008, 01:11 am
::)::)

Hay un botoncito llamado Buscar [ ::)::)] en este foro ya se a publicado la respuesta anteriormente

::)::)

pero aun asi te digo que es la API: SetMenuItemBitmaps
3230  Programación / Programación Visual Basic / Re: MODEM DSL 305EU en: 16 Septiembre 2008, 05:01 am
ante todo buenas noches, acudo esta noche a el chat por tener un problema con un modem starbritge, el modelo es fcc dsl 305eu.
 El modem es nuevo el problema que presenta es que sincroniza cuando le da la gana, saben tengo otro modem claro de diferente marca el cual en mi linea siempre funcion bien, ahora bien hay alguna configuracion que kle pueda yo realizar o es que espa desprogramado, por tener kla opcion de router? les agradezco de verdad su ayuda

Invitame de lo que te fumaste broo para estar en tu ondaaa

Esto ira aquí cuando vea elefantes Rosas ("Como en unos 15 minutos" vive la vida carnal)

ja no ya enserio por que piensas que esto va en esta parte?
Páginas: 1 ... 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 [323] 324 325 326 327 328 329 330 331
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines