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

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


  Mostrar Mensajes
Páginas: 1 2 [3] 4
21  Programación / Programación C/C++ / Re: Modificar valor en: 7 Marzo 2015, 10:54 am
Por cierto que significa la condicion esa: if(nump&(1<<i))
22  Programación / Programación C/C++ / Re: Modificar valor en: 6 Marzo 2015, 18:59 pm
Y si xj quiero cambiar 8 tengo que cambiarlo de uno  a uno, xj asi:


pixel.b.bit8 = 1;
pixel.b.bit9 = 1;
pixel.b.bit10 = 1;
pixel.b.bit11 = 1;
...

O existe alguna manera menos chapuzera?
23  Programación / Programación C/C++ / Re: Modificar valor en: 6 Marzo 2015, 18:51 pm
Muchas Gracias!! Te has ganado el cielo jeje  ;-)

24  Programación / Programación C/C++ / Re: Modificar valor en: 6 Marzo 2015, 18:42 pm
Código
  1.  
  2.  
  3. typedef struct TreintaydosBits {
  4.    unsigned bit0 : 1;
  5.    unsigned bit1 : 1;
  6.    unsigned bit2 : 1;
  7.    unsigned bit3 : 1;
  8.    unsigned bit4 : 1;
  9.    unsigned bit5 : 1;
  10.    unsigned bit6 : 1;
  11.    unsigned bit7 : 1;
  12.    unsigned bit8 : 1;
  13.    unsigned bit9 : 1;
  14.    unsigned bit10 : 1;
  15.    unsigned bit11 : 1;
  16.    unsigned bit12 : 1;
  17.    unsigned bit13 : 1;
  18.    unsigned bit14 : 1;
  19.    unsigned bit15 : 1;
  20.    unsigned bit16 : 1;
  21.    unsigned bit17 : 1;
  22.    unsigned bit18 : 1;
  23.    unsigned bit19 : 1;
  24.    unsigned bit20 : 1;
  25.    unsigned bit21 : 1;
  26.    unsigned bit22 : 1;
  27.    unsigned bit23 : 1;
  28.    unsigned bit24 : 1;
  29.    unsigned bit25 : 1;
  30.    unsigned bit26 : 1;
  31.    unsigned bit27 : 1;
  32.    unsigned bit28 : 1;
  33.    unsigned bit29 : 1;
  34.    unsigned bit30 : 1;
  35.    unsigned bit31 : 1;
  36. } TreintaydosBits;
  37.  
  38. typedef union CuatroBytes {
  39.    long n;
  40.    TreintaydosBits b;
  41. } CuatroBytes;
  42.  
  43. /**----- Prototipos -----**/
  44. void ImprimeBitsdePixel(long);
  45.  
  46. int main(int argc, char** argv) {
  47.  
  48.    CuatroBytes pixel;
  49.    // Todos los bits del pixel los ponemos a cero
  50.  
  51.    pixel.n = 0;
  52.  
  53.    printf("\nTodos los bits del pixel puestos a 0\n");
  54.    ImprimeBitsdePixel(pixel.n);
  55.    printf("\n");
  56.    pixel.b.bit10 = 1;
  57.    printf("\nPoner a 1 el bit menos significativo del canal Alfa (bit 24)\n");
  58.    ImprimeBitsdePixel(pixel.n);
  59.  
  60.    return (EXIT_SUCCESS);
  61. }
  62.  
  63. void ImprimeBitsdePixel(long nump) {
  64.  
  65.    int i;
  66.  
  67.    printf("\n+----------------+----------------+----------------+----------------+\n"
  68.            "|      ALFA      |      ROJO      |      VERDE     |      AZUL      |\n"
  69.            "+----------------+----------------+----------------+----------------+\n");
  70.    for (i = 0; i < 32; i++) {
  71.        printf("%ld ", nump);
  72.  
  73.        if (i == 7 || i == 15 || i == 23) {
  74.            printf("  ");
  75.        }
  76.    }
  77.  
  78. }
  79.  
25  Programación / Programación C/C++ / Re: Modificar valor en: 6 Marzo 2015, 18:35 pm
Nada sigo sin conseguirlo XD, me obligan a usar esa union.
26  Programación / Programación C/C++ / Re: Modificar valor en: 6 Marzo 2015, 18:09 pm
gracias por la ayuda y la paciencia.

Mira esto quiero que me saga:

Todos los bits del pixel puestos a 0
+----------------+----------------+----------------+----------------+
| ALFA | ROJO | VERDE | AZUL |
+----------------+----------------+----------------+----------------+
| 0 0 0 0 0 0 0 0| 0 0 0 0 0 0 0 0| 0 0 0 0 0 0 0 0| 0 0 0 0 0 0 0 0|

Poner a 1 el bit menos significativo del canal Alfa (bit 24)
+----------------+----------------+----------------+----------------+
| ALFA | ROJO | VERDE | AZUL |
+----------------+----------------+----------------+----------------+
| 0 0 0 0 0 0 0 1| 0 0 0 0 0 0 0 0| 0 0 0 0 0 0 0 0| 0 0 0 0 0 0 0 0|

poner solo el bit8 a con valor 1
27  Programación / Programación C/C++ / Re: Modificar valor en: 6 Marzo 2015, 18:04 pm
Me imprime 8
28  Programación / Programación C/C++ / Re: Modificar valor en: 6 Marzo 2015, 17:58 pm
Eso hice y me pone 256 a todos los bits
29  Programación / Programación C/C++ / Re: Modificar valor en: 6 Marzo 2015, 17:54 pm
La cosa es cambiar solo el valor de uno

pixel.n = 0; se ponen todos a 0

si solo solo quiero uno pensaba que se podia hacer asi pixel.b.bit2 = 0; pero no
30  Programación / Programación C/C++ / Re: Modificar valor en: 6 Marzo 2015, 17:38 pm
si si era por no pegar los 32.

Si hago lo siguiente:

// Todos los bits del pixel los ponemos a cero
    pixel.n = 0;
Páginas: 1 2 [3] 4
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines