Tag Archives: Ideas

Small but smart colorpicker

Small but smart colorpicker

The small but smart color picker

This is my attempt at making a small but smart color picker. It has two modes and can be used for live color updating. The mode shown in image is Alphamode:= True, second mode will then be Alphamode:= False which will be more aimed at web design.

To set the colorpickers color use:
SetColor(Color, Alpha, Update) or SetColor(Color, Update) where Update is a boolean which if false will set old color to color value.

Alpha is a value between 0 and 255.

To get color value use GetColor. Alpha value is stored in RGBAlpha.

Download: Color Picker (260kB)

Cool thumbnails

An extra thumbnail post, the last one for a while.  I will show you how to edit caption of the thumbnail and how you can rate it using your mouse. The main activity is done in the CellHit event so make sure that CellSelect is set to false, somehow this must be done in code so a good place to do it is in formCreate event.

Rated thumbs

Rated thumbs

Here is the code for CellHit. One thing to remember about this event is that y is counted from the bottom and not from the top as normal. This can be a bit confusing.

procedure TfrmMain.viewMainCellHit(Sender: TObject; Canvas: TCanvas; Idx, x,
  y: Integer; var Selected: Boolean);
  i: Integer;
  if (y < 20 ) then begin
    i:= 0;
    if (CellStyle = 0) and (y < 20) then i:= 1;
    if i <> CellEditIdx then begin
      CellEditIdx:= i;
  end else begin
    if CellEditIdx <> -1 then ViewMain.Invalidate;
    CellEditIdx:= -1;
  if CellStyle <> 1 then Exit;
  // Check if over rating stars
  if (x > HSX) and (x < HSX + 70) and (y < 20) then begin
    CellEditIdx:= 2;
    i:= 1 + (x - HSX) div 14;
    if i <> HotStars then begin
      HotStars:= i;
  end else begin
    if HotStars <> -1 then ViewMain.Invalidate;
    HotStars:= -1;

This event code is called whenever mouse is over a cell to check if it is selected we use it to do some checking and set some flags which we use in the OnMouseDown event.

CellEditIdx is used to signal what to check for. If it is one we simply check if mouse is in the lower part of the thumb if it is we mark it and do a repaint. The same with rating we do a check to see if it is within the rating area and do a repaint if it changes value.

In the MouseDownEvent the action is done. If rating is active the selected thumb will be updated with the current rating. If rating is not active an editbox is activated giving you a chance to change the filename of the selected thumb. Note that in demo changing the name of the thumb will not change the real name of the file, it is just for showing you how to do it.

When tumbnail component got focus you can press F8 to see some statistic of current state.

Hope this helps a little. You should also update the rkView component used in this demo as some small bugs have been fixed. I will later publish rkview as a single post in its own with some more samples.

Next post up is how to adjust brightness, contrast and saturation to an image.

Download: Cool thumbnails

A little delayed but still here!

While we are waiting for my entries I can say a little about what I have planed. The first artickel will be about image straightening. I have a working solution but I am not complete satisfied so maybe we can improve it together. I will always be open for suggestions about improvements and better way of doing stuff. I am not claiming to be a pro and lot of my solution will be based on what others have contributed.

Recently I have done some gradient variants I would like to share with you so keep on coming back. Have you ever wanted to include resizable thumbnails in your application? I have a solution and I will share it with you. It was a lot easier than I had imagined so there is no excuse for not adding it any longer… well untill you have read my artickel that is.

Working with colors have always been a little difficult and I have had to ask around sometimes. This has given me some good solutions and I planning to show you my solutions. 

This is a little about what is comming.  I hope you find it intresting and if you have any comments please tell me.

My idea of this site is to be a helping hand in graphics programming in Delphi. Finding solutions and contribute to finding solutions that  works.


Kind regards

Roy Magne Klever