Author Archive

C, Source Code

Optimized Access to Bitmaps

If we need image processing in c#, the fastest way for a programmer to access the pixels of a Bitmap is to use the SetPixel() and GetPixel() .NET methods. Unfortunately the fastest way for a programmer, often does’nt correspond to the fastest way for the program: These functions are REALLY slow, so if your objective is to analyze all pixels of an image, or, still worse, to make an elaboration of many images, you are not adviced to use them. Fortunately the c# is a very language flexible: It allows to make things at high levels, but often gives the opportunity to do low-level programming when is necessary.

For semplicity, in this article i will deal only the images at 8bpp (8 bit per pixel): every byte will be a pixel.

The only way to work fast with an image is to use the pointer to the image data. Work with the pointers is like working with the char * in c++: Initialliy, the pointer will point to the memory address of the first pixel of the bitmap. Increasing the pointer we would gradually obtain the values of the next pixels.
Pointer to image example
Continue Reading »

.NET, C, Source Code

CRC in C#

This is a post about the CRC (Cyclic Redundancy Check) in C#. I searched through the internet a C# class that can calculate the crc-12, but I found only links about crc-8, crc-16 and crc-32.

binary matrix

After an hard search, i founded a class that can calculate the crc from 1 to 32 (this is the link), I cleaned it and I added:

  • The crc-12 standard
  • A class that simplifies the insert of the values (CRCSettings)
  • A function that generate non-standard polynomys.

Continue Reading »

Wordpress, php

Problems with comments using Redoable theme in WP

If you have problems in the comments using Redoable theme, you can try this trick(i hope that this post can help someone :) ).

Open the file single.php and modify the following lines at the end of the file from:

</div>
<div id=”rightcolumn”>
<?php get_sidebar(); ?>
</div>
<div class=”clear”></div>
</div> <!– .content –>
<?php comments_template(); ?>
<?php get_footer(); ?>

To:

</div>
<?php comments_template(); ?>
<div id=”rightcolumn”>
<?php get_sidebar(); ?>
</div>
<div class=”clear”></div>
</div> <!– .content –>
<?php get_footer(); ?>

I don’t know why, but invoking comments_template() after get_sidebar() the comments will not display right.

News, Windows

Vista 3.1

Today I installed Vista with my friends and we discovered that when Microsoft says that DirectX10 can run only on Vista because they are strongly legate with the new OS they are only saying bullshits, because the new OS depends yet from Windows 3.1!! :D
Windows Vista 3.1

It’s evident in the image that the directory selection is equal to the original Windows 3.1!!
LOL! :D

php

Random image in php

If you want to show a random image in your site a good method is through a php script.
A random image example is here :)
Immagine random

You prefer the dogs, the cat or the lucky hamster? :D (refresh to randomize another image)
Continue Reading »

C, MySQL, Source Code

Convert a C# Object to a SQL string

This post is part of the SQLStringBuilder project. For the latest version of the code i suggest to take the source code from the CVS.

Every time that we need to create SQL queries in a programming language, often we do something like:

int id = GetTableID();
string place = GetPlace();
DateTime timestamp = GetLastActionDate();
string strTimestamp = Utils.GetSQLDate(DateTime.Now);
string sql = "INSERT INTO table VALUES(" + id + ",'" + place + "'," + timestamp + "')";

During the string creation we must add , ‘ and ” with attention.
In this article we will create a function that takes as input a c# Object and gives as output the formatted SQL String:

public static string GetSQLObject(object value)

Continue Reading »

.NET, C

How to use Visual Studio Snippets

Snippets are a fast and intuitive way to write ripetitive code in your project.

Let’s try the prop snippet to write a property.

Write prop in the code:

snippet property 1

Continue Reading »

Windows

Vista 3.1

Oggi ho installato Vista a casa di amici e abbiamo scoperto che quando la Microsoft dice che le DirectX10 possono girare soltanto su Windows Vista perchè fortemente legate alle nuove funzionalità del sistema operativo sta semplicemente dicendo porcate, perchè quest’ultimo in realtà dipende ancora da Windows 3.1!!!! :f2:

Windows Vista 3.1

Come si nota dall’immagine infatti la schermata di selezione della directory è rimasta ancora quella di Windows 3.1!!! Su Windows Xp era già presente questo “bug” (Pannello di controllo->Font e aggiungete un carattere), ma la Microsoft non l’ha ancora corretto nonostante questa schermata risalga ormai ai tempi preistorici! :f8:

« Prev