Форум программистов, компьютерный форум, киберфорум
Delphi: Графика, звук, видео
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.55/11: Рейтинг темы: голосов - 11, средняя оценка - 4.55
5 / 5 / 2
Регистрация: 31.05.2010
Сообщений: 80
1

Скринмейт - требуеться разобраться с кодом

04.12.2012, 09:30. Показов 1981. Ответов 3
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Доброго всем дня!
Особо этим не увлекался, но вот хочу сделать сюрприз на НГ всем:
- вывести на мониторы снеговика, который выходит слевой стороны экрана, доходит до середины и ставит елку!!!
- потом уходит, а елка остаеться на месте! )

В инете нашел пример, как делать скринмейт:

Delphi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
unit Animate;
interface
{$I RX.INC}
 
uses Messages, {$IFDEF WIN32}Windows, {$ELSE}WinTypes, WinProcs,
{$ENDIF}
SysUtils, Classes, Graphics, Controls, Forms, StdCtrls, Menus, ExtCtrls;
 
type
TGlyphOrientation = (goHorizontal, goVertical);
 
{ TRxImageControl }
TRxImageControl = class(TGraphicControl)
 
private
   FDrawing: Boolean;
protected
   FGraphic: TGraphic;
   function DoPaletteChange: Boolean;
   procedure DoPaintImage; virtual; abstract;
   procedure PaintDesignRect;
   procedure PaintImage;
   procedure PictureChanged;
 
public
   constructor Create(AOwner: TComponent); override;
end;
 
{ TAnimatedImage }
 
TAnimatedImage = class(TRxImageControl)
 
private
   { Private declarations }
   FActive: Boolean;
   FAutoSize: Boolean;
   FGlyph: TBitmap;
   FImageWidth: Integer;
   FImageHeight: Integer;
   FInactiveGlyph: Integer;
   FOrientation: TGlyphOrientation;
   FTimer: TTimer;
   FNumGlyphs: Integer;
   FGlyphNum: Integer;
   FStretch: Boolean;
   FTransparentColor: TColor;
   FOpaque: Boolean;
   FTimerRepaint: Boolean;
   FOnFrameChanged: TNotifyEvent;
   FOnStart: TNotifyEvent;
   FOnStop: TNotifyEvent;
   procedure DefineBitmapSize;
   procedure ResetImageBounds;
   procedure AdjustBounds;
   function GetInterval: Cardinal;
   procedure SetAutoSize(Value: Boolean);
   procedure SetInterval(Value: Cardinal);
   procedure SetActive(Value: Boolean);
   procedure SetOrientation(Value: TGlyphOrientation);
   procedure SetGlyph(Value: TBitmap);
   procedure SetGlyphNum(Value: Integer);
   procedure SetInactiveGlyph(Value: Integer);
   procedure SetNumGlyphs(Value: Integer);
   procedure SetStretch(Value: Boolean);
   procedure SetTransparentColor(Value: TColor);
   procedure SetOpaque(Value: Boolean);
   procedure ImageChanged(Sender: TObject);
   procedure UpdateInactive;
   procedure TimerExpired(Sender: TObject);
   function TransparentStored: Boolean;
   procedure WMSize(var Message: TWMSize); message WM_SIZE;
 
protected
   { Protected declarations }
   function GetPalette: HPALETTE; override;
   procedure Loaded; override;
   procedure Paint; override;
   procedure DoPaintImage; override;
   procedure FrameChanged; dynamic;
   procedure Start; dynamic;
   procedure Stop; dynamic;
 
public
   { Public declarations }
   constructor Create(AOwner: TComponent); override;
   destructor Destroy; override;
   procedure DoPaintImageOn(Mycanvas: Tcanvas; x, y: integer);
     virtual;
 
published
   { Published declarations }
   property Active: Boolean read FActive write SetActive default
     False;
   property Align;
   property AutoSize: Boolean read FAutoSize write SetAutoSize
     default True;
   property Orientation: TGlyphOrientation read FOrientation write
     SetOrientation
     default goHorizontal;
   property Glyph: TBitmap read FGlyph write SetGlyph;
   property GlyphNum: Integer read FGlyphNum write SetGlyphNum
     default 0;
   property Interval: Cardinal read GetInterval write SetInterval
     default 100;
   property NumGlyphs: Integer read FNumGlyphs write SetNumGlyphs
     default 1;
   property InactiveGlyph: Integer read FInactiveGlyph write
     SetInactiveGlyph default -1;
   property TransparentColor: TColor read FTransparentColor write
     SetTransparentColor
     stored TransparentStored;
   property Opaque: Boolean read FOpaque write SetOpaque default
     False;
   property Color;
   property Cursor;
   property DragCursor;
   property DragMode;
   property ParentColor default True;
   property ParentShowHint;
   property PopupMenu;
   property ShowHint;
   property Stretch: Boolean read FStretch write SetStretch default
     True;
   property Visible;
   property OnClick;
   property OnDblClick;
   property OnMouseMove;
   property OnMouseDown;
   property OnMouseUp;
   property OnDragOver;
   property OnDragDrop;
   property OnEndDrag;
 
{$IFDEF WIN32}
   property OnStartDrag;
 
{$ENDIF}
   property OnFrameChanged: TNotifyEvent read FOnFrameChanged write
     FOnFrameChanged;
   property OnStart: TNotifyEvent read FOnStart write FOnStart;
   property OnStop: TNotifyEvent read FOnStop write FOnStop;
end;
 
implementation
 
uses RxConst, VCLUtils;
 
 { TRxImageControl }
constructor TRxImageControl.Create(AOwner: TComponent);
 
begin
inherited Create(AOwner);
ControlStyle := [csClickEvents, csCaptureMouse, csOpaque,
{$IFDEF WIN32}csReplicatable, {$ENDIF}csDoubleClicks];
Height := 105;
Width := 105;
ParentColor := True;
end;
 
procedure TRxImageControl.PaintImage;
var
Save: Boolean;
begin
Save := FDrawing;
FDrawing := True;
try
   DoPaintImage;
finally
   FDrawing := Save;
end;
end;
 
 
procedure TRxImageControl.PaintDesignRect;
begin
if csDesigning in ComponentState then
   with Canvas do
   begin
     Pen.Style := psDash;
     Brush.Style := bsClear;
     Rectangle(0, 0, Width, Height);
   end;
end;
 
function TRxImageControl.DoPaletteChange: Boolean;
var
ParentForm: TCustomForm;
Tmp: TGraphic;
begin
Result := False;
Tmp := FGraphic;
if Visible and (not (csLoading in ComponentState)) and (Tmp <> nil)
{$IFDEF RX_D3} and (Tmp.PaletteModified){$ENDIF} then
begin
   if (GetPalette <> 0) then
   begin
     ParentForm := GetParentForm(Self);
     if Assigned(ParentForm) and ParentForm.Active and
       Parentform.HandleAllocated then
     begin
       if FDrawing then
         ParentForm.Perform(WM_QUERYNEWPALETTE, 0, 0)
       else
         PostMessage(ParentForm.Handle, WM_QUERYNEWPALETTE, 0, 0);
       Result := True;
 
{$IFDEF RX_D3}
       Tmp.PaletteModified := False;
 
{$ENDIF}
     end;
 
   end
 
{$IFDEF RX_D3}
   else
   begin
     Tmp.PaletteModified := False;
   end;
 
{$ENDIF}
end;
end;
 
procedure TRxImageControl.PictureChanged;
begin
if (FGraphic <> nil) then
   if DoPaletteChange and FDrawing then
     Update;
if not FDrawing then
   Invalidate;
end;
 
{ TAnimatedImage }
constructor TAnimatedImage.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FTimer := TTimer.Create(Self);
Interval := 100;
FGlyph := TBitmap.Create;
FGraphic := FGlyph;
FGlyph.OnChange := ImageChanged;
FGlyphNum := 0;
FNumGlyphs := 1;
FInactiveGlyph := -1;
FTransparentColor := clNone;
FOrientation := goHorizontal;
FAutoSize := True;
FStretch := True;
Width := 32;
Height := 32;
end;
 
destructor TAnimatedImage.Destroy;
begin
FOnFrameChanged := nil;
FOnStart := nil;
FOnStop := nil;
FGlyph.OnChange := nil;
Active := False;
FGlyph.Free;
inherited Destroy;
end;
 
procedure TAnimatedImage.Loaded;
begin
inherited Loaded;
ResetImageBounds;
UpdateInactive;
end;
 
function TAnimatedImage.GetPalette: HPALETTE;
begin
Result := 0;
if not FGlyph.Empty then
   Result := FGlyph.Palette;
end;
 
procedure TAnimatedImage.ImageChanged(Sender: TObject);
begin
FTransparentColor := FGlyph.TransparentColor and not PaletteMask;
DefineBitmapSize;
AdjustBounds;
PictureChanged;
end;
 
procedure TAnimatedImage.UpdateInactive;
begin
if (not Active) and (FInactiveGlyph >= 0) and
   (FInactiveGlyph < FNumGlyphs) and (FGlyphNum <> FInactiveGlyph) then
begin
   FGlyphNum := FInactiveGlyph;
end;
end;
 
function TAnimatedImage.TransparentStored: Boolean;
begin
Result := (FGlyph.Empty and (FTransparentColor <> clNone)) or
   ((FGlyph.TransparentColor and not PaletteMask) <>
   FTransparentColor);
end;
 
procedure TAnimatedImage.SetOpaque(Value: Boolean);
begin
if Value <> FOpaque then
begin
   FOpaque := Value;
   PictureChanged;
end;
end;
 
procedure TAnimatedImage.SetTransparentColor(Value: TColor);
begin
if Value <> TransparentColor then
begin
   FTransparentColor := Value;
   PictureChanged;
end;
end;
 
procedure TAnimatedImage.SetOrientation(Value: TGlyphOrientation);
begin
if FOrientation <> Value then
begin
   FOrientation := Value;
   DefineBitmapSize;
   AdjustBounds;
   Invalidate;
end;
end;
 
procedure TAnimatedImage.SetGlyph(Value: TBitmap);
begin
FGlyph.Assign(Value);
end;
 
procedure TAnimatedImage.SetStretch(Value: Boolean);
begin
if Value <> FStretch then
begin
   FStretch := Value;
   PictureChanged;
   if Active then
     Repaint;
end;
end;
 
procedure TAnimatedImage.SetGlyphNum(Value: Integer);
begin
if Value <> FGlyphNum then
begin
   if (Value < FNumGlyphs) and (Value >= 0) then
   begin
     FGlyphNum := Value;
     UpdateInactive;
     FrameChanged;
     PictureChanged;
   end;
end;
end;
 
procedure TAnimatedImage.SetInactiveGlyph(Value: Integer);
begin
if Value < 0 then
   Value := -1;
if Value <> FInactiveGlyph then
begin
   if (Value < FNumGlyphs) or (csLoading in ComponentState) then
   begin
     FInactiveGlyph := Value;
     UpdateInactive;
     FrameChanged;
     PictureChanged;
   end;
end;
end;
 
procedure TAnimatedImage.SetNumGlyphs(Value: Integer);
begin
FNumGlyphs := Value;
if FInactiveGlyph >= FNumGlyphs then
begin
   FInactiveGlyph := -1;
   FGlyphNum := 0;
end
else
UpdateInactive;
FrameChanged;
ResetImageBounds;
AdjustBounds;
PictureChanged;
end;
 
procedure TAnimatedImage.DefineBitmapSize;
begin
FNumGlyphs := 1;
FGlyphNum := 0;
FImageWidth := 0;
FImageHeight := 0;
if (FOrientation = goHorizontal) and (FGlyph.Height > 0) and
   (FGlyph.Width mod FGlyph.Height = 0) then
   FNumGlyphs := FGlyph.Width div FGlyph.Height
else if (FOrientation = goVertical) and (FGlyph.Width > 0) and
   (FGlyph.Height mod FGlyph.Width = 0) then
   FNumGlyphs := FGlyph.Height div FGlyph.Width;
ResetImageBounds;
end;
 
procedure TAnimatedImage.ResetImageBounds;
begin
if FNumGlyphs < 1 then
   FNumGlyphs := 1;
if FOrientation = goHorizontal then
begin
   FImageHeight := FGlyph.Height;
   FImageWidth := FGlyph.Width div FNumGlyphs;
end
else {if Orientation = goVertical then}
begin
   FImageWidth := FGlyph.Width;
   FImageHeight := FGlyph.Height div FNumGlyphs;
end;
end;
 
procedure TAnimatedImage.AdjustBounds;
begin
if not (csReading in ComponentState) then
begin
   if FAutoSize and (FImageWidth > 0) and (FImageHeight > 0) then
     SetBounds(Left, Top, FImageWidth, FImageHeight);
end;
end;
 
type
TParentControl = class(TWinControl);
Из этого кода:
1) не могу понять, в каком месте идет "ссылка" на картинку png ?
2) очучение, что много лишнего и требуеться упразднить ка-то код (минимизировать)?
3) подходит ли этот код, для того, что я хочу сделать (писал выше)?

Что исчу (что нужно):
1) вывести анимированную картинку (спрайт в 24 кадра) на экран дисплея:
- 18 кадров на движение снеговика;
- 6 кадров анимация елки;
... ну на этом пока все, т.к. в этом коде еще предстоит разобраться!

Заранее, спасибо!
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
04.12.2012, 09:30
Ответы с готовыми решениями:

Не могу разобраться разобраться с кодом меню
Добрый день. Я понимаю, что тут все, наверное, элементарно. Но я только начала изучение js и пока...

Разобраться с кодом
Код не мой, взял в инете, внедрил на свой сайт. Проблема в следующем. На последней странице выводит...

Разобраться с кодом
Для чего нужна вот эта часть кода? зачем нужен этот конструктор ? как он работает? // класс...

Разобраться с кодом
Эта функция заставляет работать ctrl+'русская буква' в tkinter. Не понимаю, что делает первая...

3
3 / 3 / 0
Регистрация: 16.05.2012
Сообщений: 20
05.12.2012, 21:16 2
Вообще-то это просто компонент "анимированная картинка".
0
angstrom
05.12.2012, 22:42 3
Получить хендл "стола" - GetDC(0) и рисовать на нём.
8 / 8 / 0
Регистрация: 13.01.2013
Сообщений: 177
13.01.2013, 19:40 4
osminog, так вы всё-таки смогли написать скринмейт на делфи? Очень важно знать
0
13.01.2013, 19:40
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
13.01.2013, 19:40
Помогаю со студенческими работами здесь

Разобраться с кодом
Здравствуйте! Помогите, пожалуйста разобраться с кодом. Моя задача. передать параметры ячейки в...

разобраться с кодом
люди добрые может кто нить написать пояснения к коду (типа это переменная, это то то, берется от...

Разобраться с кодом
Здравствуйте, начинаю изучать питон и никак не могу додуматься до решения. Нужно вывести через...

Разобраться с кодом
Очень часто встречаю код, типо PIconRec = ^TIconRec; TIconRec = packed record Width:...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
4
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru