| Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате |
| Форум программистов > Центр помощи > [Delphi] Работа с TImage в TImageList |
| Автор: Deiv 5.11.2006, 17:19 | ||||
| Привет, Для не записи несколько изображениx (images) в диске, я решил записать единственный образ 128x640 pixels (где одно букбa тянется каждое 64 pixels в 2x линиях [10 букб выше и 10 букб ниже] кажды/64 pixels) нагружая это с TIMAGELIST'om (как будто это казалось матрицей 10x2) Мой Образ имеет БЕЛОЕ дно. _________________________________________ | A | B | C | D | E | F | G | H | I | J | | K | L | M | N | O | P | Q | R | S | T | ------------------------------------------ Со следующим кодoм я положу индекс:
Как сделать ту же работу в Timage?Я попробывал c: ImageList1.BkColor:=clNone; ImageList1.BlendColor:= clNone; ImageList1.DrawingStyle:= dsTransparent; ImageList1.Masked:= True; И, Image1.Transparent:=true; BitMap.TransparentColor:=BitMap.Canvas.Pixels[0,0]; //white bottom BitMap.Transparent:= True; BitMap.TransparentMode:= tmFixed; И Я не получаю прозрачную частью BitMap'a в TImage Тянучи, Как я могу показать индекс например 15 [5,1] 5+ (1*10) =15 ПРОЗРАЧНЫЙ TImageList'a в TImage? Hello, For to avoid and save several images in disk, I decided to save a single image of 128x640 pixels (where a Letter is drawn each 64 pixels in 2 lines [10 letters above and 10 letters below] each/64 pixels) that I load it with a TImageList (as if it seemed a matrix of 10x2) My Image has WHITE bottom _________________________________________ | A | B | C | D | E | F | G | H | I | J | | K | L | M | N | O | P | Q | R | S | T | ------------------------------------------ With the following code position an index:
How to make the same work in a Timage? I have proven with ImageList1.BkColor:=clNone; ImageList1.BlendColor:= clNone; ImageList1.DrawingStyle:= dsTransparent; ImageList1.Masked:= True; and, Image1.Transparent:=true; BitMap.TransparentColor:=BitMap.Canvas.Pixels[0,0]; //white bottom BitMap.Transparent:= True; BitMap.TransparentMode:= tmFixed; And I don't get the transparent of a part of the BitMap in a TImage When drawing, How I show the index for example 15 [5,1] 5+(1*10)=15 TRANSPARENT of the TImageList in a TImage? |
| Автор: Alexeis 6.11.2006, 01:39 | ||||
| Deiv, I сan`t understand what вщ you need to do.... To copy an image from a bitmap to TImage you should simply assign it to TImage.
To get only tranparent part, you must use WINAPI function AlphaBlend. It combines two DCs with transparency Here is an example (by Snowy) which combines two bitmaps with transparency.
p.s. Don`t use Promt to translate from English into Russian. It does it badly. Nobody ever can understand these sentences. |
| Автор: Deiv 6.11.2006, 16:23 |
| Спасибо, мой вопрос был : Как сделать ту же работу в Timage? How to make the same work in a Timage? QUOTE: Here is an example (from Snowy) which combines two bitmaps with transparency. не нужно комбинировать (Dont' need to combine) Мой код показывает часть от BitMap'a в TPaintBox'e, мне нужно делать то же самое, но в TImage (прозрачной) с TImagelist'oм (Изменять мой код TPaintBox'a к TImage). My code shows a part of the BitMap in a TPaintBox, I need to do the same but in a TImage (transparent) with TImagelist. |
| Автор: Deiv 7.11.2006, 02:27 | ||||
Я подумал нужно было только изменить
чтобы показать тот кусок [15], но это не показывает мне прозрачному. Мне нужно только переводить мой Код из TPaintBox к TImage и показал мне прозрачному. Как я могу это сделать? I thought alone it would be to change with ImageList1.Draw(PaintBox1.Canvas,0,0,15) x ImageList1.Draw(Image1.Canvas,0,0,15) for to show that piece [15], but it doesn't show me transparent. I only need help in to translate my Code from a TPaintBox to a TImage and it also shows me transparent. How can I make that? |
| Автор: Alexeis 7.11.2006, 03:03 | ||
TPaintBox is just a DC, but TImage is a storage for picture. May be you need to convert internal TImage bitmap in to 32bit/color as TPaintBox has. Image1.picture.bitmap.PixelFormat := pf32bit; //default is pfDevice Or you can combine two images Image1.picture.bitmap.canvas and Image received with ImageList1.GetBitmap() (With function AlphaBlend) Result Canvas will be TImage canvas. It will give you same result as ImageList1.Draw(PaintBox1.Canvas,0,0,15) I checked this method. It works well. |
| Автор: Deiv 9.11.2006, 22:03 | ||||||||
| Я проверил код и работает очень хорошо c TTimer'om, спасибо. Сейчас у меня два вопроса: Нагружая программу, TIMAGE показывает мне белый цвет в TFORM:
Когда я нагружаю с кнопкой:
также показывает мне часть bitmap'a с белым дном 1.- Могу ли показать нагружая мою программу бездонную TImage (прозрачный)? значит без белого цвета?, и Так же со click'oм кнопки "Load Part of BitMap" TImage может показать мне непосредственно (прямо) прозрачному? 2.- Alexei Вы проверили другой Bitmap? Почему TImageList не поддерживает bitmaps 32 bits'a? I have checked the code and it works very well with TTimer, thank you. Now I have two questions: When loading the program, TImage shows me a white color in the TForm:
When I load with the button:
It also shows me the part of the BitMap with white bottom 1.- Can I show when loading my program a bottomless TImage (transparent)? that is to say without any color?, likewise to the click of the button "Load Part of BitMap" could the TIMage show me directly transparent? 2.- Alexei Have you checked the other BitMap? Why doesn't TImageList support bitmaps of 32 bits? |
| Автор: Alexeis 9.11.2006, 22:54 | ||
You need to fill alpha channel with 255 and 0 s. Zero for transparent fields and 255 for not transparent fields. This binary mask can help you draw correct transparensity. Then you made so, you can use funtion alphablend to draw transparent fields witch are filled with various color. TImageList supports addition of binary mask. It can be used for transparensy. function Add(Image, Mask: TBitmap): Integer;//see help for more information No, I checked only initial settings. |
| Автор: Deiv 10.11.2006, 02:19 | ||
Thanks, I solved it in the following way:
Only he stays to know about the bitmap of 32 bits ('Metals2.bmp'=32 bits) |